我编写链接列表用于 C# 学习
但是,为什么这段代码会出现错误。
class testClass{
testClass* pointerValue;
}
错误代码:
Cannot take the address of, get the size of, or declare a pointer to a managed type ('testClass')
我不知道为什么会出现这个错误。帮助我
最佳答案
由于testClass
已被声明为class
(而不是struct
),它是一个引用类型,并且您有不需要任何显式的不安全指针:
class testClass {
// reference to testClass instance or null
testClass pointerValue;
}
关于C# 声明类成员变量自身类型指针,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51421077/