2021年8月25日

摘要: params参数定义:将实参列表中跟可变参数数组类型一致的元素都当做数组的元素去处理 int[] Maps=new int[10]; //方法体 public static void forIntArray(int io,params int[] array) { for (int i = 0; i 阅读全文
posted @ 2021-08-25 15:32 召唤师857 阅读(642) 评论(0) 推荐(0) 编辑
 
摘要: 定义:out参数就侧重于在一个方法中可以返回多个不同类型的值 //方法体 public int Get(int i,out int x,out string name) { x=0; name=""; return i;//返回前给out参数赋值 } //调用方法 int x;//接收返回值x st 阅读全文
posted @ 2021-08-25 15:15 召唤师857 阅读(698) 评论(0) 推荐(0) 编辑
 
摘要: ref 参数定义:能够将变量带入一个方法中进行改变,改变完成后,再将改变后的值带出方法并赋值给原变量 int num1=10; int num2=20; //方法主体(变量值互换) public void Get(ref int n1,ref int n2) { int temp = n1; n1= 阅读全文
posted @ 2021-08-25 14:51 召唤师857 阅读(264) 评论(0) 推荐(0) 编辑