tailieunhanh - Declaring Methods

Phương pháp khai báo phương pháp A là một dãy có tên của báo cáo. Nếu bạn đã từng lập trình bằng cách sử dụng ngôn ngữ như C hoặc Visual Basic, một phương pháp rất giống với một chức năng hoặc trình con một. | Declaring Methods A method is a named sequence of statements. If you have previously programmed using languages such as C or Visual Basic a method is very similar to a function or a subroutine. Each method has a name and a body. The method name should be a meaningful identifier that indicates the overall purpose of the method CalculateIncomeTax for example . The method body contains the actual statements to be run when the method is called. Most methods can be given some data for processing and can return information which is usually the result of the processing. Methods are a fundamental and powerful mechanism. Specifying the Method Declaration Syntax The syntax of a Microsoft Visual C method is as follows returnType methodName parameterList method body statements go here The returnType is the name of a type and specifies what kind of information the method returns. This can be the name of any type such as int or string. If you re writing a method that does not return a value you must use the keyword void in place of the return type. The methodName is the name used to call the method. Method names must follow the same identifier rules as variable names. For example addValues is a valid method name whereas add Values is not valid. For now you should use camelCase for method names and you should start them with a verb to make them descriptive for example displayCustomer. The parameterList is optional and describes the types and names of the information that you can pass into the method. You write the parameters between the left and right parentheses as though you re declaring variables with the name of the type followed by the name of the parameter. If the method you re writing has two or more parameters you must separate them with commas. The method body statements are the lines of code that are run when the method is called. They are enclosed between opening and closing curly braces . IMPORTANT C C and Microsoft Visual Basic programmers should note that C does not

crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.