如果继承不熟练,写起来也是费劲的;
- #region 重新方法技术点; 1111
- ///
- /// 父类;
- ///
- class Vecetables
- {
- public void Fot(string a, int b)
- {
- Console.WriteLine("我叫{0}是父类的第{1}个方法", a, b);
- }
- }
-
- ///
- /// 子类;
- ///
- /// 继承父类点; 1 父类 子类的明确区分!
- ///
- class XC : Vecetables
- {
-
- }
-
- //父类2;
- public class FuLei
- {
- // 同时锻炼方法中参数的使用; 2个参数;
- public void Add_FotherM(string b,int a)
- {
- Console.WriteLine("我叫{0}是父类的第{1}个方法",b,a);
- }
-
-
- }
-
- //继承;
- class ZiLei : FuLei
- {
-
- }
-
-
- //2 表示JSON对象
-
-
- #endregion
控制台主函数调用;
#region 重写方法;
Vecetables ve = new Vecetables();//父类的对象
XC xc = new XC();//子类的对象
ve.Fot("张三", 1);//父类的方法
xc.Fot("李四", 1);//子类的方法
//2
FuLei fuobj = new FuLei(); //父类的实例化 对象;1
ZiLei ziobj = new ZiLei(); // 2 子类的实例化 1个对象;
//调用父类中的方法;
fuobj.Add_FotherM( "调试数据值内容1", 1);
//调用子类中的方法;
ziobj.Add_FotherM("子类",2);
Console.ReadLine();
#endregion
效果
