C# Programming - Structures - Discussion

Discussion Forum : Structures - General Questions (Q.No. 13)
13.
Which of the following will be the correct output for the C#.NET program given below?
namespace IndiabixConsoleApplication
{ 
    struct Sample
    { 
        public int i;
    }
    class MyProgram
    { 
        static void Main(string[] args)
        {
            Sample x = new Sample(); 
            x.i = 10; 
            fun(ref x); 
            Console.Write(x.i + " ");
        }
        public static void fun(ref Sample y)
        { 
            y.i = 20;
            Console.Write(y.i + " "); 
        } 
    } 
}
20 10
10 20
10 10
20 20
None of the above
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
1 comments Page 1 of 1.

Abhishek Jha said:   1 decade ago
Ref Keyword used as function parameter when we have to modify the value in calling function.

Post your comments here:

Your comments will be displayed after verification.