Examveda

What will be the output of the following C# code?
static void main(string[] args)
{
    int n = 1;
    method(n);
    console.Writeline(n);
    method1(ref n);
    console.Writeline(n);
}
static void method(int num)
{
    num += 20;
    console.writeline(num);
}
static void method1(ref int num)
{
    num += 20;
    console.writeline(num);
}

A. 1
1
1
1

B. 21
1
21
21

C. 11
21
21
11

D. Error

Answer: Option B


Join The Discussion

Related Questions on Arrays and Strings in C Sharp