Compiler Error CS0214
Collapse the table of content
Expand the table of content
This documentation is archived and is not being maintained.

Compiler Error CS0214

Pointers may only be used in an unsafe context

Pointers can only be used with the unsafe keyword.

The following sample generates CS0214:

// CS0214.cs
public struct S
   public int a;

public class a
   public static int Main()
   // try the following line instead
   // unsafe public static int Main()
      S s = new S();
      S * s2 = &s;    // CS0214
      s2->a = 3;      // CS0214

      return 1;
© 2016 Microsoft