我不打算实现一个结构树,但是我得到了一个TypeLoadException。
Console.WriteLine(typeof(Node)); // throw TypeLoadException
public struct Node
{
public StructList<Node> Sons;
}
public struct StructList<T>
{
}发布于 2022-07-28 05:14:20
我决定了。
public unsafe class Node
{
private StructList _children;
public ref StructList<Node> Children => ref Unsafe.AsRef<StructList<Node>>(Unsafe.AsPointer(ref _children));
[StructLayout(LayoutKind.Sequential)]
private struct StructList
{
private IntPtr _array;
private int _size;
private int _length;
}
}
[StructLayout(LayoutKind.Sequential)]
public struct StructList<T>
{
private IntPtr _array;
private int _size;
private int _length;
}https://stackoverflow.com/questions/73136296
复制相似问题