Beispiel #1
0
        public static void Func1()
        {
            int    a = 32;
            object o = a;

            Console.WriteLine(a + "," + o);
            Console.WriteLine(a.ToString() + "," + o);

            var mvt = new MyValueType();

            mvt.GetHashCode();                   //不会装箱,方法内没有基类实现
            mvt.ToString();                      //会装箱,方法内有基类实现
            mvt.GetType();                       //会装箱,该方法由System.Object定义
            mvt.Clone();                         //不会装箱,值类型实现了接口
            var         ic  = mvt as ICloneable; //会装箱,转化为某个接口
            IComparable icc = mvt;               //会装箱,转化为某个接口
        }
Beispiel #2
0
 public static bool ExternFunc(this MyValueType objs, object obj)
 {
     return(false);
 }