This week's research covers various types of classes and application scenarios. Static class static methods, understanding of static classes, and application scenarios.One point in the book is as follows:
1 whether the type is static or not, it can
Issue: Field or property problem field initializers cannot reference non-static fields, methodsWhy is the field defined in the class not available because of an error in the following code? Public string Text = test ();//Hint field or property
Deep understanding of C # static and non-static classes, static members of the differenceStatic classThe important difference between a static class and a non-static class is that a static class cannot be instantiated, that is, a variable of a
When a field declaration containsstatic modifier, the field introduced by the declaration is a static field (static variable). When there is nostaticmodifier, the field introduced by the declaration is an instance field (instance variable). A static
Static is a modifier that declares a static field, a static method, or a static class. A field that uses static declarations belongs to the type itself and does not belong to any field, and the declared class also has some special features, such as
C # language has a lot to learn, here we mainly introduce C # static fields and C # instance fields, including the introduction of the ReadOnly keyword is used to fame a read-only field.
C # static fields and C # instance fields
Fields have C #
1. The structure in C # can be defined using the struct keyword in C #. The level and class are consistent and written under the namespace. 1) attributes, fields, methods, and constructors can be defined in the structure. The sample code is as
Original blog, reprint please indicate the source--Zhou Xuewei http://www.cnblogs.com/zxouxuewei/Static is used in two ways: static in process-oriented programming and static in object-oriented programming. The former applies to ordinary variables
C # BASICS (7)-differences between static and non-static classes and static members,
Static class
An important difference between static and non-static classes is that static classes cannot be instantiated.That is to say, you cannot use the new
static variables
The static variable is on the stack and is a global variable that has been generated at compile time.
public class Cow
{public
static int count;
private int id;
Public Cow ()
{
id = ++count
}
}
The client creates 2 cow
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.