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.

 

 


posted @ 2010-03-16 14:56  能巴  阅读(366)  评论(0编辑  收藏  举报