- 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.
- The DevOps 2.3 Toolkit
- Unreal Engine Physics Essentials
- Mobile Web Performance Optimization
- Ceph Cookbook
- Mastering Spring MVC 4
- HTML5 Mobile Development Cookbook
- Servlet/JSP深入詳解
- Mastering JavaScript Design Patterns(Second Edition)
- 精通MATLAB(第3版)
- 軟件測試實用教程
- PLC應用技術(三菱FX2N系列)
- Instant Debian:Build a Web Server
- Python編程:從入門到實踐(第3版)
- Python網絡爬蟲實例教程(視頻講解版)
- Oracle Database 12c DBA官方手冊(第8版)