adplus-dvertising
frame-decoration

Question

What will be the output of the given code?
class UnsafeCode
{
    unsafe static void Main()
    {
        int a = 2;
        int b = 4;
        int *a1 = &a;
        int *b1 = &b;
        Console.WriteLine(*a1 + *b1);
    }
}

a.

6

b.

print garbage value

c.

print -6

d.

print address of b + a

Answer: (a).6

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What will be the output of the given code?