关于.Net结构的信息 [英] Regarding Information of .Net structers

查看:70
本文介绍了关于.Net结构的信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

1)为什么structer是从接口进入的?为什么它不是从类中继承?

2)我们将实时使用结构(原始数据类型)?

3)默认情况下将结构设计为密封类型的意图是什么

1) why structer is inherting from interfaces and why not it is inherting from classes?
2) where we will use structers in real time apart from (primitive data types )?
3) what is the intention of designing structers as sealed types by default

推荐答案

我们不做你的功课:设置是有原因的。它就是为了让你思考你被告知的事情,并试着理解它。它也在那里,以便您的导师可以识别您身体虚弱的区域,并将更多的注意力集中在补救措施上。



亲自尝试,你可能会发现它不是你想的很难!



但是有一些提示:



1)有什么区别在 struct 之间?您可以从引用类型逻辑派生类型吗?如果你这样做会得到什么?

2)我们需要的任何地方。 类型优于参考类型的优势是什么?

3)什么如果他们不是密封
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!

However a few hints are:

1) What is the difference between as struct and a class? Can you logically derive a value type from a reference type? What would you get if you did?
2) Anywhere we need to. What is the advantage of a value type over a reference type?
3) What can you do with them if they aren''t sealed?


0)Structers不存在。



1)不是一个有效的问题。因为它是这样设计的。如果您询问如何以不同的方式进行设计,则应解释所有设计。但是结构可能如何从类中继承?类是引用类型,结构是值类型。



2)无处,因为使用CLR的操作系统不是实时系统。 :-)这个问题没有任何意义,不仅仅是因为你滥用实时一词,而是一般。



3)因为这是这样设计的。问问.NET的创建者。我知道一些结构可以继承的系统。这很有趣:这个问题被多次提出,有些成员总是提供理性的解释。他们都是纯粹的幻觉。事实上,没有这样的解释。也许他们只是不想让系统变得更加复杂。但是结构之间的继承没有什么困难。



-SA
0) "Structers" do not exist.

1) Not a valid question. Because it''s designed this way. If you are asking how to design in a different way, you should explain all of your design. But how structures would possibly inherit from classes? Classes are reference types, structures are value types.

2) Nowhere, because OS using CLR are not real time systems. :-) The question makes no sense not just because of your misuse of the term "real time", but in general.

3) Because this is designed this way. Ask the creators of .NET. I know some systems where structures can inherit. It''s funny: this question was asked many times, and some members always provided "rational" explanations. They are all purely illusionary. In fact, there is no such explanation. Perhaps they just did not want to make the system more complex than it has to be. But there is nothing too difficult about inheritance between structures.

—SA


这篇关于关于.Net结构的信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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