using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//namespace DeleDemo
//{
// public delegate void MyDele();
// public class Myclass
// {
// public void MyFun()
// {
// Program p = new Program();
// p.My();
// }
// }
// class Program
// {
// //引用
// public int a=10;
// public MyDele My;
// public event MyDele myevent;
// void Function(int s,int a=123)
// {
// //a = 30;
// Console.WriteLine("bbb");
// }
// static void Main(string[] args)
// {
// Program p = new Program();
// p.My = () => Console.WriteLine("aaa");
// //p.My += p.Function;
// //p.My -= p.Function;
// //执行委托对象,会执行委托对象身上所有的方法
// // p.My();
// //p.myevent();
// int num = 20;
// p.Function(5);
// // p.Function(ref num);
// Console.WriteLine(num);
// Console.ReadKey();
// }
// }
//}
定义方法时传递的参数叫形式参数,简称形参。
调用方法时传递的参数叫实际参数,简称实参。
引用参数:使用ref关键字修饰
调用方法时复制实参变量在栈中的引用。
作用 改变数据 语法 (ref 数据类型 参数名)
输出参数 使用out 关键字修饰
调用方法时复制实参变量在栈中的引用
作用返回结果 语法:…out 数据类型 参数名
与引用参数的区别:ref 要求实参必须在传递前进行赋值
out 要求形参离开方法前必须赋值