zoukankan      html  css  js  c++  java
  • 一个关于boxing和unboxing的demo

    demo 来自 CLR via C#(第三版)

    View Code
     1 static void Main(string[] args)
     2         {
     3             Point p = new Point(1, 1);
     4             Console.WriteLine(p);
     5 
     6             p.Change(2, 2);
     7             Console.WriteLine(p);
     8 
     9             Object o = p;
    10             Console.WriteLine(o);
    11 
    12             ((Point)o).Change(3, 3);
    13             Console.WriteLine(o);
    14 
    15             ((IChangeBoxedPoint)p).Change(4, 4);
    16             Console.WriteLine(p);
    17 
    18             ((IChangeBoxedPoint)o).Change(5, 5);
    19             Console.WriteLine(o);
    20          }
    View Code
     1     public interface IChangeBoxedPoint
     2     {
     3         void Change(Int32 x, Int32 y);
     4     }
     5 
     6     public struct Point : IChangeBoxedPoint
     7     {
     8         private Int32 m_x, m_y;
     9         public Point(Int32 x, Int32 y)
    10         {
    11             m_x = x;
    12             m_y = y;
    13         }
    14 
    15         public void Change(Int32 x, Int32 y)
    16         {
    17             m_x = x;
    18             m_y = y;
    19         }
    20 
    21         public override string ToString()
    22         {
    23             return string.Format("({0},{1})", m_x, m_y);
    24         }
    25     }
  • 相关阅读:
    argparse模块的使用
    tf.stack() /tf.unstack()
    什么是tensor
    tf.size()函数
    tf.nn.l2_loss()的用法
    CNN中的卷积
    tf.reverse()
    学习音视频编程技术 博客
    shell 批量计算MD5值
    线程池的实现
  • 原文地址:https://www.cnblogs.com/swanestle/p/2647164.html
Copyright © 2011-2022 走看看