C # All types derive from Object type _c# tutorial

Source: Internet
Author: User
The CLR requires that each type is eventually derived from the object type, as follows:
Class Typer {} = = = Class Typer:object {}

The top is exactly the same.

All types are ultimately derived from object, and each type has a set of most basic methods:

Equals: Returns True if two objects are equal
GetHashCode: Returns a hash code for the object value
ToString: The full name of the default return type, int, and other types are overridden
GetType: Returns the type of the object called

Also, derived types from object can access protected methods

MemberwiseClone: Returns a new real class
Finalize: Virtual method, called before memory recycle

The CLR requires that all objects be created with the new operator:

1, the calculation type and all of the base types, there are some additional members
2, from the heap allocation specified type requirements of the number of bytes
3, the instance constructor of the calling type is passed in to any arguments specified in the call to new.

Each type constructor, when invoked, is responsible for initializing the instance field of this type definition, and ultimately invoking the constructor of object.

After new executes, returns a reference to the new object.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.