The role of the static keyword in C #

Source: Internet
Author: User
There are two types of static allocations:
1. Used in the class of properties, methods, such static properties and methods do not need to create an instance can be accessed, through the class name or object names can access it, static properties, methods only "one copy": That is, if a class has a new n objects, the n objects only the same static property and method;
2. Static variables inside the method:
Static variables inside the method, the execution of the static variable value does not disappear, the method of executing this object again, the value still exists, it is not allocated in the stack, is in the static zone analysis, which is the largest difference with local variables;

The role of the static keyword in C #

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.