This documentation is archived and is not being maintained.

Compiler Error CS0208

Cannot take the address or size of a variable of a managed type ('S')

Even when used with the unsafe keyword, taking the address of a managed object is not allowed. For more information on managed objects, see A.2 Pointer types.

The following sample generates CS0208:

// CS0208.cs
// compile with: /unsafe

class S
   public int a = 98;

public class a
   unsafe public static int Main()
      S s = new S();  // S is managed
      S * s2 = &s;    // CS0208
      return 1;