I l @ ve RuBoard |
Another way to define variables is through the use of formal method parameters. Table D.1 outlines the four types of method parameters. Table D.1. Parameter Types in C#
Consider the following class, which employs each of the parameter types: using System; class Test { public void ValueParamMethod(int a) { a += 2; // the original parameter is not modified } public void RefParamMethod(ref int a) { a += 2; // the original parameter is not modified } public void OutParamMethod(out int a) { a = 2; // original value unimportant, a set to 2 and passed out } public void ParamArrayMethod(params int[] args) { // provides flexibility through indefinite number of arguments } } |
I l @ ve RuBoard |