官术网_书友最值得收藏!

The general form of a class

To create a class in C#, you have to follow a particular syntax. The general form of this is as follows:

class class-name {
// this is class body
}

The class phrase is a reserved keyword in C#, and it is used to tell the compiler that we want to create a class. To create a class, place the class keyword and then the name of the class after a space. The name of the class can be anything that starts with a character or an underscore. We can also include numbers in the class name, but not the first character of a class name. After the chosen name of the class, you have to put an opening curly brace, which denotes the start of the class body. You can add content in the class, such as properties and methods, and then finish the class with a closing curly brace, as follows:

class class-name {
// property 1
// property 2
// ...

// method 1
// method 2
// ...
}

There are other keywords that can be used with classes to add more functionality, such as access modifiers, virtual methods, partial methods, and so on. Don't worry about these keywords or their uses, as we will discuss these later in this book.

主站蜘蛛池模板: 米林县| 宿州市| 凤凰县| 颍上县| 绵阳市| 鸡西市| 田东县| 定陶县| 体育| 金寨县| 抚远县| 招远市| 乌兰浩特市| 英山县| 富平县| 托克托县| 白山市| 辉县市| 抚远县| 图们市| 宜兰县| 竹山县| 曲阜市| 上犹县| 福清市| 莆田市| 正镶白旗| 迁西县| 舟曲县| 鹤岗市| 铁力市| 瑞金市| 密云县| 桦川县| 德安县| 彰武县| 东丰县| 澄江县| 苍南县| 汶川县| 阿克|