- 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.
- 大話PLC(輕松動漫版)
- Python機器學習:數(shù)據(jù)分析與評分卡建模(微課版)
- Visual C++串口通信開發(fā)入門與編程實踐
- Visual Basic程序設(shè)計(第3版):學習指導與練習
- OpenCV for Secret Agents
- 面向?qū)ο蟪绦蛟O(shè)計(Java版)
- Python漫游數(shù)學王國:高等數(shù)學、線性代數(shù)、數(shù)理統(tǒng)計及運籌學
- Java編程技術(shù)與項目實戰(zhàn)(第2版)
- H5頁面設(shè)計:Mugeda版(微課版)
- Asynchronous Android Programming(Second Edition)
- Go語言精進之路:從新手到高手的編程思想、方法和技巧(1)
- Express Web Application Development
- PHP從入門到精通(第4版)(軟件開發(fā)視頻大講堂)
- 劍指大數(shù)據(jù):企業(yè)級數(shù)據(jù)倉庫項目實戰(zhàn)(在線教育版)
- Java 9 Programming By Example