CG 函数

函数

与C#函数的语法一致
无返回值函数 void FunctionName(参数类型 参数…){}
有返回值 type FunctionName(参数类型 参数){return type}

in关键字

in关键字可以修饰参数类型
修饰的参数作为输入参数 在函数内部使用
函数内部不能修改

void Test(in int a){
    
     b=a+10;}
Test(20)

out关键字

out关键字可以修饰参数类型
修饰的参数做为输出参数
必须在函数内部进行赋值
可以作为返回值进行使用

void Test(out int b){
    
     b=10}
int c;
Test(c)

猜你喜欢

转载自blog.csdn.net/weixin_43796392/article/details/134722909