C # function parameters,

Source: Internet
Author: User

C # function parameters,

When the function accepts parameters, the subordinate content must be specified.

  • Parameter Match: when calling a function, you must make the parameter exactly match the parameter specified in the function definition. This means that the parameter type, number, and order must be matched.
  • Parameter Array

    C # Allow a function to specify one (only one) specific parameter. This parameter must be the last parameter in the function definition, called the parameter array, the parameter array can be defined by calling a function with an indefinite number of parameters.

  • Value Parameter

    It means that when a value parameter is used, a value is passed to a variable used by the function. Any modification to this value in the function does not affect the specified parameter in the function call, therefore, the output I value below is still 5;

  • Reference parameter (ref keyword): the variables processed by the function are the same as those used by the function call, not just the variables with the same value, therefore, any modification to this variable will affect the output parameter of the variable value used as the parameter.

    Two restrictions for using the ref parameter: first, the variable cannot be a constant, and the initialized variable must be used.

  • Output parameter (Out keyword): similar to ref, but different
    • It is invalid to use unassigned variables as the ref parameter, but you can use unassigned parameters as the Out parameter.
    • When the Out parameter is used in a function, the Out parameter is considered to be unassigned. Therefore, you must initialize the Out parameter before using the function. Otherwise, the following error is reported;


In the C language, what is the symbol (->) and how to use it?

This is a symbol in the struct pointer. Write a program to explain it, for example:
# Include <stdio. h>
Struct STU // define a struct
{
Int num;
} Stu;
Int main ()
{
Struct STU * p; // defines a struct pointer.
P = stu; // p points to the struct variable stu.
Stu. num = 100; // attaches an initial value to the struct member num.
Printf ("% d", p-> num); // output the num value in stu
Return;
}
As you can see, the-> method is to reference the variable in the struct !!
Format: p-> struct member (such as p-> num)
The function is equivalent to stu. num or (* p). num.
I don't know. You don't understand, and don't understand call me. O (∩ _ ∩) O ~
Hope to adopt it.

In the C language, what is the symbol (->) and how to use it?

This is a symbol in the struct pointer. Write a program to explain it, for example:
# Include <stdio. h>
Struct STU // define a struct
{
Int num;
} Stu;
Int main ()
{
Struct STU * p; // defines a struct pointer.
P = stu; // p points to the struct variable stu.
Stu. num = 100; // attaches an initial value to the struct member num.
Printf ("% d", p-> num); // output the num value in stu
Return;
}
As you can see, the-> method is to reference the variable in the struct !!
Format: p-> struct member (such as p-> num)
The function is equivalent to stu. num or (* p). num.
I don't know. You don't understand, and don't understand call me. O (∩ _ ∩) O ~
Hope to adopt it.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.