Windows Phone Developers

Tuesday, November 25, 2008

Output Parameters in C# (.NET)


An output parameter is declared with the out modifier.

private static void ParamExample(double radius, out double Area, out double Perimeter)

{

const double pi = 22/7;

Area = pi * radius * radius;

Perimeter = 2 * pi * radius;

}

It is similar to a reference parameter except that the initial value of the caller-provided argument is unimportant.

double rad = 10.0;

double area;

double pm;

ParamExample(rad, out area, out pm);

Console.WriteLine("For a circle of radius {0} : Area is {1} and Perimeter is {2}", rad, area, pm);




output parameter in .NET


See also

How to get the return value from C# program (console application)

Command Line Arguments in C#

How to Return Multiple Values from a VBA Function


Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

2 comments:

  1. Thanks, this was exactly what I was after.

    ReplyDelete
  2. Its good to know that C# Supports Multiple Inheritance,Multiple inheritance allows a class to take on functionality from multiple other classes.

    ReplyDelete