myclasscollection.cs

来自「ajax的应用实例 是个很好的学习例子 对初学者用很打帮助」· CS 代码 · 共 66 行

CS
66
字号
using System;
using System.Collections;
using AJAXDemo.Examples.Classes;

namespace AJAXDemo.Examples.Collections
{
	public class MyClassCollection : CollectionBase  
	{

		public MyClass this[ int index ]  
		{
			get  
			{
				return( (MyClass) List[index] );
			}
			set  
			{
				List[index] = value;
			}
		}

		public int Add( MyClass value )  
		{
			return( List.Add( value ) );
		}

		public int IndexOf( MyClass value )  
		{
			return( List.IndexOf( value ) );
		}

		public void Insert( int index, MyClass value )  
		{
			List.Insert( index, value );
		}

		public void Remove( MyClass value )  
		{
			List.Remove( value );
		}

		public bool Contains( MyClass value )  
		{
			// If value is not of type Int16, this will return false.
			return( List.Contains( value ) );
		}

		protected override void OnInsert( int index, Object value )  
		{
		}

		protected override void OnRemove( int index, Object value )  
		{
		}

		protected override void OnSet( int index, Object oldValue, Object newValue )  
		{
		}

		protected override void OnValidate( Object value )  
		{
		}

	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?