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

后端 未结 3 618
傲寒
傲寒 2021-01-20 15:56

this error stops compiling if i have one or more System.String in my structs
is there any other way to store strings?

i have tried things like this:

         


        
3条回答
  •  北海茫月
    2021-01-20 16:23

    Try the MarshalAs attribute:

    struct Foo
    {
        [MarshalAs(UnmanagedType.LPStr]
        string s;
    }
    

提交回复
热议问题