- Hands-On Object:Oriented Programming with C#
- Raihan Taher
- 192字
- 2021-07-02 12:44:41
Methods in a class
Let's talk about another important topic—namely methods. A method is a piece of code that is written in the code file and can be reused. A method can hold many lines of code, which will be executed when it is called. Let's take a look at the general form of a method:
access-modifier return-type method-name(parameter-list) {
// method body
}
We can see that the first thing in the method declaration is an access-modifier. This will set the access permission of the method. Then, we have the return-type of the method, which will hold the type that the method will return, such as string, int, double, or another type. After that, we have the method-name and then brackets, (), which indicate that it is a method. In the brackets, we have the parameter-list. This can either be empty or can contain one or more parameters. Finally, we have curly brackets, {}, which hold the method body. The code that the method will execute goes inside here.
Any code following this structure will be considered a method by the C# compiler.
- Getting Started with Citrix XenApp? 7.6
- Data Visualization with D3 4.x Cookbook(Second Edition)
- MATLAB圖像處理超級學(xué)習(xí)手冊
- 程序員面試筆試寶典
- Web開發(fā)的貴族:ASP.NET 3.5+SQL Server 2008
- R語言編程指南
- Python程序設(shè)計案例教程
- FLL+WRO樂高機器人競賽教程:機械、巡線與PID
- C程序設(shè)計案例教程
- Hands-On GPU:Accelerated Computer Vision with OpenCV and CUDA
- Developing SSRS Reports for Dynamics AX
- Scratch從入門到精通
- 基于GPU加速的計算機視覺編程:使用OpenCV和CUDA實時處理復(fù)雜圖像數(shù)據(jù)
- 數(shù)據(jù)結(jié)構(gòu):Python語言描述
- PHP Microservices