adplus-dvertising
frame-decoration

Question

What will be the output of the given code segment?
class UnsafeCode
{
    unsafe static void Main()
    {
         int n = 10;
         void* p = &n;
         Console.WriteLine(*p);
         Console.ReadLine();
     }
 }

a.

The program will print 10

b.

Run time error

c.

Compile time error

d.

Output is the address contained in p

Posted under C# programming

Answer: (c).Compile time error

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 segment?