csharp out parameters
string myString = ""; int myInt = 0; myInt = CalculateMyInt(myInt, out myString); Console.WriteLine(myString);//"Hello World" Console.WriteLine(myInt);//123 public int CalculateMyInt(int theInt, out string theString) { theString = "Hello World";//set the String return theInt + 123;//return the int }
Example of using an out parameter, which is defined outside of the scope of the function, assigned a value within the function and then displayed after calling the function.
Updated: Thursday 4th August 2011, 02:15am
There are 0 comments
Comments are currently closed.