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

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.

主站蜘蛛池模板: 界首市| 沈阳市| 马尔康县| 吉木萨尔县| 家居| 莎车县| 大兴区| 固始县| 徐水县| 西青区| 新兴县| 正镶白旗| 大新县| 广丰县| 锦屏县| 开鲁县| 宁波市| 中方县| 紫金县| 黎平县| 天镇县| 荥阳市| 虹口区| 青河县| 万年县| 盐边县| 尚志市| 贵溪市| 凯里市| 察雅县| 隆尧县| 额济纳旗| 鸡西市| 抚松县| 嵊州市| 清远市| 西丰县| 太仆寺旗| 长海县| 平凉市| 岗巴县|