C # enumerations, structs, classes

Source: Internet
Author: User

First, enumerate

Enum Keyword: enum

Enum Sex

{

Man

Woman

}

Enum Cnumber

0 = 0,

one = 1,

Ii. = 2,

Second, the structural body

Structure of the keyword struck

Structure definition:

Struck Struckname

{

Public data type variable name;// in a struct declaration, it cannot be initialized unless the field is declared const or static.

public void function name () {};

Public Struckname (parameter) {}// struct cannot declare a default constructor (a constructor without parameters) or a destructor , but can declare a constructor with parameters

}

Declaration instantiation:

Struckname STK = new Struckname ();//The instantiation of a struct may not use the new operator, so struckname Stk;

Third, class

class's keyword class

Definition of Class

Class MyClass

{

MyClass ()

{

destructor body.

}

}

Declaration instantiation:

MyClass MyClass = new MyClass ();

C # enumerations, structs, classes

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.