. Static and non-static classes, static and non-static members in net

Source: Internet
Author: User

As the title, such a lot of information online, but also said very in place, but all feel a lot of explanation, theoretical too strong, here I briefly summarize and summarize the difference between them, can be at a glance:

I. Static and non-static classes

Definition:

Static classes can be considered as a single process in a class library, and there is no concept of "state";

Non-static class is a kind of operation procedure that stores stateful

Summary:

A non-static class can contain static methods;

Static classes can only contain static methods (no non-static methods are allowed to exist)

Two. Static and non-static methods (instance methods)

Priority in Memory when Class Loaded:

Class loads at load time: Static variables----and non-static members/variables (after class instantiation)

Access Different:

In C #, non-static methods can access static and non-static members, but static methods can only access static members

(A static member is a resource that you share, and a static method does not belong to an instance, so a non-static member (instance member) cannot be called)

. Static and non-static classes, static and non-static members in net

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.