using System;using System.Collections;using System.Text;namespace Generics{ public class aList<T> : CollectionBase where T:new () { public aList(){ } public T this[int index]{ get { return (T)List[index]; } set { List[index] = value; } } public int Add(T value){return List.Add(value);} } class Program { static void Main(string[] args) { aList<Customer> customers = new aList<Customer>(); customers.Add(new Customer("Motown-Jobs")); customers.Add(new Customer("Fatman's")); foreach (Customer c in customers) Console.WriteLine(c.CustomerName); Console.ReadLine(); } } public class Customer { private string customerName = ""; public string CustomerName { get { return customerName; } set { customerName = value; } } public Customer(string customerName) { this.customerName = customerName; } public Customer() { } }}

被折叠的 条评论
为什么被折叠?



