S
sloan
I'm not the sharpest knife in the drawer, but not a dummy either.
I'm looking for a good book which goes over Generics in great detail.
and to have as a reference book on my shelf.
Personal Experience Only, Please.
...
My 1.1 CollectionBase objects look like this most of the time.
I'm trying to determine if I can *always* get the *exact same* functionality
with generics.......
public class CustomerCollection : System.Collections.CollectionBase
{
public void Add ( BusinessObjects.Customer cust )
{
base.InnerList.Add(cust);
}
public BusinessObjects.Customer this[int index]
{
get
{
return (BusinessObjects.Customer )base.InnerList[index];
}
}
public BusinessObjects.Customer Contains( string custId )
{
foreach( BusinessObjects.Customer item in base.InnerList )
if( item.CustomerID .Equals(custId) )
{
return item;
}
return null;
}
public BusinessObjects.Customer Remove(string custId)
{
// remove the object, but also return it.
BusinessObjects.Customer returnObject = null;
returnObject = this.Contains(custId);
if (null != returnObject )
{
base.InnerList.Remove (returnObject);
}
return returnObject;
}
protected override void OnValidate(object value)
{
base.OnValidate(value);
if (!(value is BusinessObjects.Customer))
{
throw new ArgumentException("Collection only supports Customer
objects.");
}
}
}
I'm looking for a good book which goes over Generics in great detail.
and to have as a reference book on my shelf.
Personal Experience Only, Please.
...
My 1.1 CollectionBase objects look like this most of the time.
I'm trying to determine if I can *always* get the *exact same* functionality
with generics.......
public class CustomerCollection : System.Collections.CollectionBase
{
public void Add ( BusinessObjects.Customer cust )
{
base.InnerList.Add(cust);
}
public BusinessObjects.Customer this[int index]
{
get
{
return (BusinessObjects.Customer )base.InnerList[index];
}
}
public BusinessObjects.Customer Contains( string custId )
{
foreach( BusinessObjects.Customer item in base.InnerList )
if( item.CustomerID .Equals(custId) )
{
return item;
}
return null;
}
public BusinessObjects.Customer Remove(string custId)
{
// remove the object, but also return it.
BusinessObjects.Customer returnObject = null;
returnObject = this.Contains(custId);
if (null != returnObject )
{
base.InnerList.Remove (returnObject);
}
return returnObject;
}
protected override void OnValidate(object value)
{
base.OnValidate(value);
if (!(value is BusinessObjects.Customer))
{
throw new ArgumentException("Collection only supports Customer
objects.");
}
}
}