zoukankan      html  css  js  c++  java
  • 装箱 拆箱

    using System;
    using System.Collections;
    using System.Diagnostics;
    using UnityEngine;
    /// <summary>
    /// 装箱 拆箱
    /// </summary>
    public class Text05 : MonoBehaviour {
    
        void Start () {
            int n = 10;
            object o = n;//装箱
            int nn = (int)o;//拆箱
    
            //这地方没有发生 装拆箱
            string str = "123";
            int str1 = Convert.ToInt32(str);
    
            int int1 = 11;
            IComparable i = int1;//装箱
    
            //Encasement();
    
        }
        /// <summary>
        /// 装箱测试
        /// </summary>
        public void Encasement() {
            ArrayList list = new ArrayList();
            //List<int> list =new List<int> ();
            //这里面发生了1000次装箱操作
            Stopwatch sw = new Stopwatch();
            //00:00:00.0008463 (装箱)
            //00:00:00.0006876(未装箱)
            //装箱会消耗内存时耗 尽量避免装箱
            sw.Start();
            for (int i = 0; i < 10000; i++)
            {
                list.Add(i);
            }
            sw.Stop();
            print(sw.Elapsed);
        }
    }
  • 相关阅读:
    hrbust1279
    U盘快捷方式中毒处理办法
    计算几何
    poj1113
    凸包模版
    STL容器
    HDU2048
    HDU2047
    HDU2045
    python面试题总结
  • 原文地址:https://www.cnblogs.com/mclll520/p/8073733.html
Copyright © 2011-2022 走看看