zoukankan      html  css  js  c++  java
  • 索引器

            class myListBox
            {
                    protected ArrayList data = new ArrayList();
                    public object this[int idx]
                    {
                            get
                            {
                                    if(idx > -1 && idx < data.Count)
                                    {
                                            return (data[idx]);
                                    }
                                    else
                                    {
                                            // possibly throw an exception here
                                            return null;
                                    }
                            }
                            set
                            {
                                    if(idx > -1 && idx < data.Count)
                                    {
                                            data[idx] = value;
                                    }
                                    else if (idx == data.Count)
                                    {
                                            data.Add(value);
                                    }
                                    else
                                    {
                                            // possibly throw an exception here
                                    }
                            }
                    }
            }
        class TestApp
            {
                    [STAThread]
                    static void Main(string[] args)
                    {
                            myListBox lBox = new myListBox();
                            lBox[0] = "First";
                            lBox[1] = "Second";
                            lBox[2] = "Third";
                            Console.WriteLine("{0},{1},{2}",lBox[0],lBox[1],lBox[2]);
                    }
            }
  • 相关阅读:
    吞吐量(TPS)、QPS、并发数、响应时间(RT)
    吞吐量(TPS)、QPS、并发数、响应时间(RT)
    ubuntu 14.04安装pycharm 社区版
    ubuntu 14.04安装pycharm 社区版
    卷积神经网络(4)----目标检测
    卷积神经网络(4)----目标检测
    卷积神经网络(4)----目标检测
    如何搭建自己CDN服务器
    flask
    s16 计算机网络基础
  • 原文地址:https://www.cnblogs.com/kevinge/p/1337198.html
Copyright © 2011-2022 走看看