Sachin Chauhan

Sachin Chauhan

  • NA
  • 21
  • 9.1k

out keyword in C#

Mar 2 2013 3:42 AM

 Hi All,

When i am executing the below below program, I am getting the output as 10 while i am not assigning the val1 to i. So can anybody tell me plz why it is happening?

 

class Class1

{

int i;

int Method1(out int val1)

{

val1 = 10;

return i;

}

public static void Main(String[] args)

{

int x;

Class1 cls = new Class1();

cls.Method1(

out x);

Console.WriteLine(x);

Console.ReadLine();

}

}

v

Answers (1)