c# Method Parameters

In C#, you have four types of method parameters: value, ref, out, and params.

1. The default parameter type is value.

2. If you want calling code to see changes to a value type variable, the parameter type should be ref. Ref parameters definitely must be assigned before passing them to a method.

3. Out Parameters Besides using return statements, another way to return information from a method is via out parameters. You would typically use an out parameter if the return value was already being used for another purpose. 

The purpose of a params parameter is to allow you to create methods that will accept a
variable number of arguments.

4. The purpose of a params parameter is to allow you to create methods that will accept avariable number of arguments.


原文地址:https://www.cnblogs.com/taoxu0903/p/1687245.html