Examveda

What will be the output of the following C# code snippet?
class UnsafeCode
{
    unsafe static void Main()
    {
        int[] nums = new int[10];
        fixed (int* p = &nums[0], p2 = nums)
        {
            if (p == p2)
            Console.WriteLine("p and p2 point to same address.");
            Console.ReadLine();
        }
    }
}

A. Run time error

B. Compile time error

C. p and p2 point to the same address

D. Only p2

Answer: Option C


This Question Belongs to C Sharp Programming >> Miscellaneous In C Sharp

Join The Discussion

Related Questions on Miscellaneous in C Sharp