static void Main8(string[] args) { //这里用的是Child的默认实例构造器, 他不是什么也不做而是调用了基类的无参构造器 //并且用基类的方法看到基类的private成员也没有问题 Child c = new Child(2); c.Log(); //Test1(); //Test2(); Console.WriteLine(~3); Parent p = 5; //call implicit cast operator p.Log(); Int32 x = (Int32)p; //call explicit cast operator Console.WriteLine(x.ToString()); //像single, int等基元类型, F12查看元数据列表, 会发现没有类型转换操作符的定义, 这些基元类型的转换代码是直接生成IL代码的 System.Single example_float = 0; //Decimal是一个很好的样板, 如何来定义自己类型的各种操作符重载, 转换操作符等 System.Decimal example_decimal = 0; //调用定义在CLRviaCSharp中的一个扩展方法 example_float.LogMe(); string something = "helloworldy"; something.PrintList(); c.ExtentLog(); }