函数2

it2025-01-27  32

十五、输出参数out

(一)定义

输出参数用于从方法体内把数据传出到调用代码。

输出参数的几个使用要求:

1)必须在声明和调用中都是用修饰符out

2)实参必须是变量,不能是其他类型的表达式。

(二)格式

static void Main(string[] args) { int a = 0; int b = 1; Program hanshu = new Program(); hanshu.Out(out a, out b); } public void Out(out int a, out int b) {//out相当于return返回值 //可以返回多个值 //拿过来变量名的时候,里面默认为空值 a = 1; b = 2; }

 

转载于:https://www.cnblogs.com/bosamvs/p/5491044.html

最新回复(0)