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

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.

主站蜘蛛池模板: 呼和浩特市| 江门市| 巫山县| 福海县| 贡嘎县| 枣庄市| 泗阳县| 阳城县| 镇原县| 宁明县| 南汇区| 双柏县| 图们市| 蓬溪县| 车致| 西林县| 曲沃县| 遂昌县| 石首市| 新疆| 铅山县| 剑阁县| 沂源县| 金乡县| 南城县| 新泰市| 彩票| 巧家县| 南岸区| 龙陵县| 哈密市| 略阳县| 醴陵市| 临泉县| 乌兰察布市| 广丰县| 丰镇市| 德昌县| 桃江县| 保德县| 旬阳县|