如下类,我不能理解那个this.count,  我没有看到count的定义,请大神帮忙解释一下,非常感谢.
public class FieldParameters : System.Collections.CollectionBase
    {
        /// <summary>
        /// 增加参数
        /// </summary>
        /// <param name="item"></param>
        public void Add(FieldItem item)
        {
            if (Find(item.Name) > -1)
            {
                throw new ArgumentException("The field name has existed!");
            }
            List.Add(item);
        }        public int Find(string fieldName)
        {
            for (int i = 0; i < this.Count; i++)
            {
                if (this[i].Name == fieldName)
                    return i;
            }
            return -1;

        }

解决方案 »

  1.   

    Count在基类System.Collections.CollectionBase上定义的
    继承了
      

  2.   

    可以看下父类System.Collections.CollectionBase  是否有
      

  3.   

    首先你的 FieldParameters 类 继承了 System.Collections.CollectionBase 抽象类,Count属性是在System.Collections.CollectionBase抽象类中定义了
      

  4.   

    在CollectionBase定义的。你可以选中Count,点右键,转到定义。
      

  5.   


    你不是继承了 System.Collections.CollectionBase吗?这里的this.count就表示当前实例中的元素的数量.
      

  6.   

    是不是     List.Items.Count ?
      

  7.   

    System.Collections.CollectionBase中找Count的定义!
      

  8.   

    CollectionBase的元数据:// 摘要:
        //     为强类型集合提供 abstract 基类。
        [Serializable]
        [ComVisible(true)]
        public abstract class CollectionBase : IList, ICollection, IEnumerable
        {
            // 摘要:
            //     使用默认初始容量初始化 System.Collections.CollectionBase 类的新实例。
            protected CollectionBase();
            //
            // 摘要:
            //     使用指定的容量初始化 System.Collections.CollectionBase 类的新实例。
            //
            // 参数:
            //   capacity:
            //     新列表最初可以存储的元素数。
            protected CollectionBase(int capacity);        // 摘要:
            //     获取或设置 System.Collections.CollectionBase 可包含的元素数。
            //
            // 返回结果:
            //     System.Collections.CollectionBase 可包含的元素数。
            //
            // 异常:
            //   System.ArgumentOutOfRangeException:
            //     System.Collections.CollectionBase.Capacity 设置为小于 System.Collections.CollectionBase.Count
            //     的值。
            //
            //   System.OutOfMemoryException:
            //     系统中没有足够的可用内存。
            [ComVisible(false)]
            public int Capacity { get; set; }
            //
            // 摘要:
            //     获取包含在 System.Collections.CollectionBase 实例中的元素数。不能重写此属性。
            //
            // 返回结果:
            //     包含在 System.Collections.CollectionBase 实例中的元素数。检索此属性的值的运算复杂度为 O(1)。
            public int Count { get; }  //你要找的Count
            //
            // 摘要:
            //     获取一个 System.Collections.ArrayList,它包含 System.Collections.CollectionBase 实例中元素的列表。
            //
            // 返回结果:
            //     表示 System.Collections.CollectionBase 实例本身的 System.Collections.ArrayList。检索此属性的值的运算复杂度为
            //     O(1)。
            protected ArrayList InnerList { get; }
            //
            // 摘要:
            //     获取一个 System.Collections.IList,它包含 System.Collections.CollectionBase 实例中元素的列表。
            //
            // 返回结果:
            //     表示 System.Collections.CollectionBase 实例本身的 System.Collections.IList。
            protected IList List { get; }        // 摘要:
            //     从 System.Collections.CollectionBase 实例移除所有对象。不能重写此方法。
            public void Clear();
            //
            // 摘要:
            //     返回循环访问 System.Collections.CollectionBase 实例的枚举器。
            //
            // 返回结果:
            //     用于 System.Collections.CollectionBase 实例的 System.Collections.IEnumerator。
            public IEnumerator GetEnumerator();
            //
            // 摘要:
            //     当清除 System.Collections.CollectionBase 实例的内容时执行其他自定义进程。
            protected virtual void OnClear();
            //
            // 摘要:
            //     在清除 System.Collections.CollectionBase 实例的内容之后执行其他自定义进程。
            protected virtual void OnClearComplete();
            //
            // 摘要:
            //     在向 System.Collections.CollectionBase 实例中插入新元素之前执行其他自定义进程。
            //
            // 参数:
            //   index:
            //     从零开始的索引,在该处插入 value。
            //
            //   value:
            //     index 处的元素的新值。
            protected virtual void OnInsert(int index, object value);
            //
            // 摘要:
            //     在向 System.Collections.CollectionBase 实例中插入新元素之后执行其他自定义进程。
            //
            // 参数:
            //   index:
            //     从零开始的索引,在该处插入 value。
            //
            //   value:
            //     index 处的元素的新值。
            protected virtual void OnInsertComplete(int index, object value);
            //
            // 摘要:
            //     当从 System.Collections.CollectionBase 实例移除元素时执行其他自定义进程。
            //
            // 参数:
            //   index:
            //     从零开始的索引,可在该位置找到 value。
            //
            //   value:
            //     要从 index 移除的元素的值。
            protected virtual void OnRemove(int index, object value);
            //
            // 摘要:
            //     在从 System.Collections.CollectionBase 实例中移除元素之后执行其他自定义进程。
            //
            // 参数:
            //   index:
            //     从零开始的索引,可在该位置找到 value。
            //
            //   value:
            //     要从 index 移除的元素的值。
            protected virtual void OnRemoveComplete(int index, object value);
            //
            // 摘要:
            //     当在 System.Collections.CollectionBase 实例中设置值之前执行其他自定义进程。
            //
            // 参数:
            //   index:
            //     从零开始的索引,可在该位置找到 oldValue。
            //
            //   oldValue:
            //     要用 newValue 替换的值。
            //
            //   newValue:
            //     index 处的元素的新值。
            protected virtual void OnSet(int index, object oldValue, object newValue);
            //
            // 摘要:
            //     当在 System.Collections.CollectionBase 实例中设置值后执行其他自定义进程。
            //
            // 参数:
            //   index:
            //     从零开始的索引,可在该位置找到 oldValue。
            //
            //   oldValue:
            //     要用 newValue 替换的值。
            //
            //   newValue:
            //     index 处的元素的新值。
            protected virtual void OnSetComplete(int index, object oldValue, object newValue);
            //
            // 摘要:
            //     当验证值时执行其他自定义进程。
            //
            // 参数:
            //   value:
            //     要验证的对象。
            //
            // 异常:
            //   System.ArgumentNullException:
            //     value 为 null。
            protected virtual void OnValidate(object value);
            //
            // 摘要:
            //     移除 System.Collections.CollectionBase 实例的指定索引处的元素。此方法不可重写。
            //
            // 参数:
            //   index:
            //     要移除的元素的从零开始的索引。
            //
            // 异常:
            //   System.ArgumentOutOfRangeException:
            //     index 小于零。- 或 -index 等于或大于 System.Collections.CollectionBase.Count。
            public void RemoveAt(int index);
        }
      

  9.   

    System.Collections.CollectionBase里面的一个属性罢了!