5
Answers

Unsafe code

Ask a question
Maha

Maha

10y
1.2k
1
This program (1st one) is given in the following website.
http://www.dotnetperls.com/unsafe

When I tried to compile error message is "Unsafe code may only appear if compiling with /unsafe". Please explain the reason.

using System;

class Program
{
unsafe static void Main()
{
fixed (char* value = "sam")
{
char* ptr = value;
while (*ptr != '\0')
{
Console.WriteLine(*ptr);
++ptr;
}
}
}
}


Answers (5)