C # Call of static and non-static members

Source: Internet
Author: User

Some information should be obtained for accessing the Internet for static and non-static problems. The following describes some materials.

It should be a non-static member that depends on the instance, so it can also be called an instance Member.

Class members include:

Data member:
Data members can be divided into static variables and instance variables.
Static member: a static member variable is associated with a class and can be used as a "common" variable in the class (a common expression). It does not depend on the existence of a specific object, you can use the class name adding operator and variable name to access the service.
Instance Member: The instance member variable is associated with the object, and the access instance member variable depends on the existence of the instance.

Function member:
Methods can be divided into static methods and instance methods.
Static Method: static method is a method that does not belong to a specific object. Static methods can access static member variables. Static methods cannot directly access instance variables. In the case of instance function calls, the instance variables are passed as parameters to the static method. Static methods cannot directly call instance methods. They can be called indirectly. First, you must create a class instance and then call the instance method through this specific object, but you can call static methods.
Instance method: the execution of an instance method is associated with a specific object. Its execution requires an object to exist. The instance method can directly access static variables and instance variables. The instance method can directly access the instance method and static method. The static method can be accessed by adding a variable name to the class name operator. When multiple instance objects exist, the memory does not contain copies of a specific instance method. Instead, all objects of the same class share a copy of each instance method (the instance method only occupies one set of space ).

TheArticleReproduced from the network base camp: http://www.xrss.cn/Info/10951.Html

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.