Export (0) Print
Expand All
Expand Minimize
0 out of 10 rated this helpful - Rate this topic

Compiler Error CS0208 

Error Message

Cannot take the address of, get the size of, or declare a pointer to a managed type ('type')

Even when used with the unsafe keyword, taking the address of a managed object, getting the size of a managed object, or declaring a pointer to a managed type is not allowed. For more information, see Unsafe Code and Pointers (C# Programming Guide).

Example

The following sample generates CS0208:

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

class S
{
    public int a = 98;
}

public class MyClass
{
    unsafe public static int Main()
    {
        S s = new S();  // S is managed
        S * s2 = &s;    // CS0208
        return 1;
    }
}
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.