T
Tony
Hello!
Here I have a collection class Cards which is derived from the Base class
CollectionBase.
This class Cards is a container for Card object.
Now to my question at the bottom of this class we have a method called
Contains.
It gived the same result to use InnerList and List in this method Contains.
I can also just replace List with InnerList in the method Add and it works.
So is the InnerList the same as List because I can use whichever of these
two ?
public class Cards : CollectionBase
{
public Cards() {}
public void Add(Card newCard)
{
List.Add(newCard);
}
public void Remove(Card oldCard)
{
List.Remove(oldCard);
}
public Card this[int cardIndex]
{
get { return (Card)List[cardIndex]; }
set { List[cardIndex] = value; }
}
public void CopyTo(Cards targetCards)
{
for (int index = 0; index < this.Count; index++)
targetCards[index] = this[index];
}
public bool Contains(Card card)
{
bool test1,test2;
test1 = InnerList.Contains(card);
test2 = List.Contains(card);
return true;
}
}
//Tony
Here I have a collection class Cards which is derived from the Base class
CollectionBase.
This class Cards is a container for Card object.
Now to my question at the bottom of this class we have a method called
Contains.
It gived the same result to use InnerList and List in this method Contains.
I can also just replace List with InnerList in the method Add and it works.
So is the InnerList the same as List because I can use whichever of these
two ?
public class Cards : CollectionBase
{
public Cards() {}
public void Add(Card newCard)
{
List.Add(newCard);
}
public void Remove(Card oldCard)
{
List.Remove(oldCard);
}
public Card this[int cardIndex]
{
get { return (Card)List[cardIndex]; }
set { List[cardIndex] = value; }
}
public void CopyTo(Cards targetCards)
{
for (int index = 0; index < this.Count; index++)
targetCards[index] = this[index];
}
public bool Contains(Card card)
{
bool test1,test2;
test1 = InnerList.Contains(card);
test2 = List.Contains(card);
return true;
}
}
//Tony