C#中的struct构造的基类 [英] Base class of struct construct in C#

查看:517
本文介绍了C#中的struct构造的基类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

http://msdn.microsoft.com/en-us/ library / ah19swz4(v = VS.71).aspx

根据上面的链接... ..但是,Structs继承了基类Object ......

As per the above link….. "Structs, however, inherit from the base class Object……"

按照以下链接
http://msdn.microsoft.com/en-us/library/system.valuetype.aspx
Struct在层次结构中的ValueType之后实现。

As per the below link http://msdn.microsoft.com/en-us/library/system.valuetype.aspx Struct is implemented after ValueType in the hierarchy.

struct派生自哪个类?或者编译器处理struct保留字,使用struct作为值类型的任何声明?
缺少整体理解中的小线程。
谢谢您的帮助。
Smith

"struct" is derived from which class? Or compiler treats "struct" reserve word to make any declaration using "struct" as value type? Missing the small thread in overall understanding. Thank you for your help. Smith

推荐答案

层次结构(跳过任何类别子类型)是:

The hierarchies (skipping any class subtypes) are:


  1. struct .. - > ValueType - >对象

class .. - >对象

演示:

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#中的struct构造的基类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆