Home
Manage Your Code
Snippet: Collection Class starter (C#)
Title: Collection Class starter Language: C#
Description: Uses People as a starting collection. Views: 428
Author: Dan Kengott Date Added: 3/2/2007
Copy Code  
1public class People {
2	public string FirstName;
3	public string LastName;
4}
5
6public class PeopleCollection : CollectionBase {
7	public void Add(People _people) {
8		List.Add(_people);
9	}
10
11	public void Remove(int index) {
12		if ((index > (Count - 1)) || (index < 0))
13			throw (new Exception("Index not for PeopleCollection valid!"));
14		List.RemoveAt(index);
15	}
16
17	public virtual People this[int index] {
18		get {
19			return (People)this.List[index];
20		}
21	}
22}