- Hands-On Object:Oriented Programming with C#
- Raihan Taher
- 225字
- 2021-07-02 12:44:40
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.
- 零基礎(chǔ)學(xué)Visual C++第3版
- 案例式C語言程序設(shè)計(jì)
- 程序設(shè)計(jì)與實(shí)踐(VB.NET)
- Learning PostgreSQL
- SQL Server 2012數(shù)據(jù)庫技術(shù)及應(yīng)用(微課版·第5版)
- HTML5 Mobile Development Cookbook
- Python神經(jīng)網(wǎng)絡(luò)項(xiàng)目實(shí)戰(zhàn)
- Spring Cloud、Nginx高并發(fā)核心編程
- Python數(shù)據(jù)分析(第2版)
- Oracle Database 12c Security Cookbook
- SAS數(shù)據(jù)統(tǒng)計(jì)分析與編程實(shí)踐
- 快人一步:系統(tǒng)性能提高之道
- 蘋果的產(chǎn)品設(shè)計(jì)之道:創(chuàng)建優(yōu)秀產(chǎn)品、服務(wù)和用戶體驗(yàn)的七個(gè)原則
- Learning Splunk Web Framework
- 超好玩的Scratch 3.5少兒編程