/// <summary>/// 扩展方法/// 静态类里的静态方法,参数列表最前面加个this +要扩展到的类型/// 使用场景:在不不修改源代码的情况下为其他类型添加方法/// </summary>public class ExtendMethod{public void Show(){Calculate calculate = new Calculate();calculate.AddNew(1, 2, 3);int i = 0;i.ToInt();}}class Calculate{public int Add(int a,int b){return a + b;}}/// <summary>/// 扩展类扩展方法,必须为静态类静态方法/// </summary>static class ClaculateNew{public static int AddNew(this Calculate calculate, int a, int b,int c){return a + b+c;}public static void ToInt(this int i){}}