中国高校课件下载中心 》 教学资源 》 大学文库

Microsoft .NET(PPT课件讲稿)Being Objects and A Glimpse into Coding

文档信息
资源类别:文库
文档格式:PPTX
文档页数:43
文件大小:839.58KB
团购合买:点击进入团购
内容简介
Microsoft .NET(PPT课件讲稿)Being Objects and A Glimpse into Coding
刷新页面文档预览

Microsoft net 5.1 Being Objects and A glimpse into Coding Pan Wuming 2017

Microsoft .NET 5.1 Being Objects and A Glimpse into Coding Pan Wuming 2017

opICS Sematic Conformity: Object Class Comparisons Between Objects To Overload the equality operator To Override the GetHashCode method To Override the tostring method Memberwise clone method The getty )e method References Object Class(MSDN) C# Operators( MSDN) Hash function(Wikipedia)

Topics • Sematic Conformity: Object Class • Comparisons Between Objects • To Overload the Equality operator • To Override The GetHashCode Method • To Override The ToString Method • MemberwiseClone Method • The GetType Method References: Object Class(MSDN) C# Operators(MSDN) Hash function (Wikipedia)

Sematic Conformity: Object Class The ultimate base class of all classes in the net framework To provides ou.laval carica ta darian claccac. Languages The root of the type hierarchy eritance from Object The inheritance is implicit

Sematic Conformity: Object Class • The ultimate base class of all classes in the .NET Framework. • To provides low-level services to derived classes. • Languages typically do not require a class to declare inheritance from Object. The root of the type hierarchy The inheritance is implicit

67 namespace leaching lass Aclass .. public class Object #egon程序集 mscorlib. version400 Culture=neutral PublicKey Token=b77a 5c561934e089 bjB) //C: Program Files(x86)\Reference assemblies \Microsoft\ Framework \.NETFramework v40 mscorlib. dll .pu #eregion proL Find All Reterences Shift+F12

The Definition of Object Class From metadata of #region 程序集 mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 // C:\Program Files (x86)\Reference Assemblies \Microsoft\Framework \.NETFramework\v4.0\mscorlib.dll #endregion

Derived classes can override these methods equals Finalize e GetHash Code ToString

Derived classes can override these methods: • Equals • Finalize • GetHashCode • ToString

The destructor implicitly calls Finalize on the base class of the object Therefore, the destructor code is implicitly translated to the following code protected override void Finalize try / cleanup statements finall base.Finalize()

• The destructor implicitly calls Finalize on the base class of the object. Therefore, the destructor code is implicitly translated to the following code:

Supports comparisons between objects lblic static bool Equals(object objA, Object objB) iblis static bool ReferenceEquals(object objA, Object objB) public virtual be uals(ObJect obJ)j Determines whether the specified Object instances are the same instance

Supports comparisons between objects Determines whether the specified Object instances are the same instance

The equals(Object) method The current instance is a reference type: Tests for reference equality The cur Equivalent to a call to the ReferenceEquals Thet Thevmethod

The Equals(Object) method • The current instance is a reference type: Tests for reference equality • The current instance is a value type: • The two objects are of the same type • The values of the public and private fields of the two objects are equal Equivalent to a call to the ReferenceEquals method

The static Equals(Object, Object) method IF The two objects represent the same object reference or both are null, it returns true If Either obja or objB is null, it returns false If the two objects do not represent the same object reference and neither is null, it calls objA. Equals objB) if obja overrides the Object Equals(Object) method this override is called

The static Equals(Object, Object) method • IF The two objects represent the same object reference, or both are null, it returns True. • If Either objA or objB is null, it returns false. • If the two objects do not represent the same object reference and neither is null, it calls objA.Equals(objB) if objA overrides the Object. Equals(Object) method, this override is called

a CSharp Blank Window 日X

刷新页面下载完整文档
VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
相关文档