我有以下简单的测试:
class C<T>
{
public struct A
{
int x;
}
}
class Program
{
static unsafe void Main(string[] args)
{
IntPtr p = new IntPtr();
var a = (C<int>.A*)p.ToPointer();
}
}
该代码生成错误 CS0208:
Cannot take the address of, get the size of, or declare a pointer to a managed
type ('C<int>.A')
有人能解释一下为什么在这种情况下struct被认为是“托管”的吗?