开发者

System.Object in C#, .NET

开发者 https://www.devze.com 2023-04-09 22:16 出处:网络
I don\'t really understand the second question, is my answer to the second question correct? Which of the following is not a method of System.Object?

I don't really understand the second question, is my answer to the second question correct?

  1. Which of the following is not a method of System.Object?
  2. What is the most generic (least derived) interface or subclass of System.Object of which it is a method?

    a开发者_运维百科. GetType()

    b. ToString()

    c. Equals(object obj)

    d. Clone()

My Answers:

Clone() is not a method of System.Object.

ICloneable for Clone. System.Object is the root type, the rest of the methods are its direct members.

What is the answer to the second question? What does it mean?

Any advice would be very much appreciated.


Your answer to the first question is of course correct. Proof.

The second question means, that if you had interface IExtendedCloneable which would derive from ICloneable (had ICloneable as parent interface), it would not be a corect answer, because ICloneable is more generic (less derived) - it is closer to object on the inheritance tree.

If there wasn't that restriction, you could say that Clone() is a member of System.Windows.Forms.Control.ControlCollection and you would be right, but the answer wouldn't be really relevant.

Thanks to that restriction, ICloneable is the answer.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号