重构:- void Change()
- {
- int a = 15, b = 20;
- a = a + b;
- b = a - b;
- a = a - b;
- Console.WriteLine("交换变量的值 a={0},b={1}", a, b);
- Console.ReadKey();
- }
复制代码- void Change()
- {
- int a = 15, b = 20;
- int tem;
- tem = a;
- a = b;
- b = tem;
- Console.WriteLine("交换变量的值 a={0},b={1}", a, b);
- Console.ReadKey();
- }
复制代码 重载:重写:- 父类
- class String
- {……
- copy()
- ……}
- 接着写他的子类
- class String1 based String
- {
- copy(); //重写父类的方法以实现第一种复制功能
- }
- class String2 based String
- {
- copy(); //重写以实现第二种复制功能
- }
复制代码
|