Create a class in C # (in update)

Source: Internet
Author: User

Class is the most common type of reference, the simplest of which is defined as

Class youclassnam{}

A complex class might contain a bit of content

Class attribute Class property and class modifier. Non-nested class modifiers are: Public,internal,abstract,sealed,static, unsafe,partial

Class name various type parameters, unique base class, multiple interfaces

Inside curly Braces Class members (methods, member properties, indexers, events, fields, constructor methods, operator functions, nested types, and terminators)

1----> Fields

A field is a variable in a class or struct body.

Fields do not have to be initialized, and fields that are not initialized are assigned a default value (0,\0,null,false). Field initialization statements are executed before the method is constructed

A read-only field can be assigned only at the time of declaration or in the class construction method to which it belongs, and cannot be changed after the assignment.

Multiple fields can be declared by a colleague

Class myone{
static readonly int leg=8,eye=2; string name; public int age=10; }

The following modifiers can be used to modify a field

static modifier--------------Static

Access permission modifier----------public internal private protected

Inheritance modifier--------------New

Insecure code modifier--------Unsafe

Read-only modifier--------------readonly

Cross-thread access modifier--------volatile

Create a class in C # (in update)

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.