zoukankan      html  css  js  c++  java
  • CollectionBase的使用

        interface IItem
    {
    object name { get; set; }
    object value { get; set; }
    void getItemByName();
    }

    public class ItemClass : IItem
    {
    #region IItem 成员

    public object name
    {
    get
    {
    throw new NotImplementedException();
    }
    set
    {
    throw new NotImplementedException();
    }
    }

    public object value
    {
    get
    {
    throw new NotImplementedException();
    }
    set
    {
    throw new NotImplementedException();
    }
    }

    public void getItemByName()
    {
    throw new NotImplementedException();
    }

    #endregion
    }
    public class ItemCollection : CollectionBase
    {
    public void Add(ItemClass item)
    {}

    public ItemClass this[int i]
    {
    get
    {
    return this.InnerList[i] as ItemClass;
    }
    }

    public ItemClass this[string name]
    {
    get
    {
    ItemClass reItem
    = null;
    ArrayList lists
    = this.InnerList;
    for (int i = 0; i < lists.Count; i++)
    {
    ItemClass item
    = lists[i] as ItemClass;
    if (string.Compare(name, item.name.ToString()) == 0)
    {
    reItem
    = item;
    }
    }
    return reItem;
    }
    }
    }

    这样就可以通过索引或键值来找到对应的item了。

  • 相关阅读:
    ②.kubernetes service
    c2p
    ⑤.docker dockerfile
    ④.docker volume
    ②.docker image
    ③.docker container
    ①.docker介绍
    三剑客之grep
    ⑦.shell 数组
    shell 正则
  • 原文地址:https://www.cnblogs.com/xingbinggong/p/2128959.html
Copyright © 2011-2022 走看看