M
MFRASER
I am trying to create a collection object that contains an internal
hashtable to help in retrieving data, but what I have relized is that I am
adding the object multiple times is there a way to add a key that points to
the reference of the object or do I not understand the hashtable?
Here is the reasoning behind my madness, I wanted a collection that the user
could enumerate through using the foreach, I also wanted a collection that
was quick to retrieve data.
Here is my code
public class MyDateCollection: ICollectionBase
{
private System.Collections.Hashtable m_IternalCollection =
new Hashtale();
...
//Here is my add method
public void Add(MyDate Item)
{
//Add to internal Hashtable
if(!this.m_IternalCollection.Contains(Item.ItemDate)
this.m_IternalCollection.Add(Item.ItemDate, Item);
if(!this.m_IternalCollection.Contains("Day" + Item.ItemDate.Date)
this.m_IternalCollection.Add("Day" + Item.ItemDate.Date, Item);
//Add to Collection
base.InnerList.Add(Item);
}
public MyDate this[System.DateTime TestDate, bool DayOnly]
{
get
{
if (DayOnly)
return (MyDate)this.m_IternalCollection["Day" +
TestDate.Date];
else
return (MyDate)this.m_IternalCollection[TestDate];
}
}
}
hashtable to help in retrieving data, but what I have relized is that I am
adding the object multiple times is there a way to add a key that points to
the reference of the object or do I not understand the hashtable?
Here is the reasoning behind my madness, I wanted a collection that the user
could enumerate through using the foreach, I also wanted a collection that
was quick to retrieve data.
Here is my code
public class MyDateCollection: ICollectionBase
{
private System.Collections.Hashtable m_IternalCollection =
new Hashtale();
...
//Here is my add method
public void Add(MyDate Item)
{
//Add to internal Hashtable
if(!this.m_IternalCollection.Contains(Item.ItemDate)
this.m_IternalCollection.Add(Item.ItemDate, Item);
if(!this.m_IternalCollection.Contains("Day" + Item.ItemDate.Date)
this.m_IternalCollection.Add("Day" + Item.ItemDate.Date, Item);
//Add to Collection
base.InnerList.Add(Item);
}
public MyDate this[System.DateTime TestDate, bool DayOnly]
{
get
{
if (DayOnly)
return (MyDate)this.m_IternalCollection["Day" +
TestDate.Date];
else
return (MyDate)this.m_IternalCollection[TestDate];
}
}
}