What's OUT Keyword?

What's OUT Keyword?

OUT:-out keyword is used for passing a variable for output purpose. It has same concept as ref keyword, but passing a ref parameter needs variable to be initialized while out parameter is passed without initialized.
It is useful when we want to return more than one value from the method.



Example of out keyword:
class Test
{
public static void Main()
{
int a;
fun(out a);
Console.WriteLine("The value of a is " + a);
}

public static void fun(out int i) 
{
i=4; //must assigned value.
}
}

The program will result : The value of a is 4

By:kamal
Date:2012-10-10 00:00:00

Post Your Answers


User Email:

User Name:
Answers:

Related C Links

C interview questions and answers for experienced and fresher