http://msdn.microsoft.com/en-us/library/ah19swz4(v=VS.71).aspx
根据上面的链接……..“但是,结构是从基类 Object 继承的……”
按照下面的链接 http://msdn.microsoft.com/en-us/library/system.valuetype.aspx Struct 在层次结构中的 ValueType 之后实现。
“struct”派生自哪个类?或者编译器将“struct”保留字视为使用“struct”作为值类型的任何声明? 缺少整体理解中的细线。 谢谢您的帮助。 史密斯
最佳答案
层次结构(跳过任何类子类型)是:
struct .. -> ValueType -> Object
类 .. -> 对象
演示:
struct S {}
class C {}
// or see `is` as per Jeff Mercado's comment
typeof(ValueType).IsAssignableFrom(typeof(S)); // True
typeof(object).IsAssignableFrom(typeof(S)); // True
typeof(ValueType).IsAssignableFrom(typeof(C)); // False
typeof(object).IsAssignableFrom(typeof(C)); // True
关于c# - C#中struct构造的基类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11461789/