Болтун
Зарегистрирован: 11 September 2003
Сообщения: 340
Примеры кода: 3
|
вот это все что мне нужно было :) |
04 April 2005 13:56 |
|
|
|
|
public class Material
{
public class ElementsCollection
{
private ArrayList els = new ArrayList();
public Element this[int index]
{
get
{
if (index < 0 || index >= this.els.Count)
throw new IndexOutOfRangeException("Index out of range.");
return (Element)els[index];
}
}
public Element this[string name]
{
get
{
foreach (object el in els)
{
if (((Element)el).Name == name)
return (Element)el;
}
throw new ArgumentException("Incorrect argument");
}
}
public int Count { get { return els.Count; } }
#region Methods
public int Add(object newObj)
{
return els.Add(newObj);
}
public void AddRange(object[] newObjs)
{
foreach (object var in newObjs)
this.Add(var);
} #endregion
}
private ElementsCollection collection = new ElementsCollection();
#region .ctor
public Material(params Element[] elements)
{
collection.AddRange(elements);
}
#endregion
public ElementsCollection Element
{
get { return this.collection; }
}
public int CountOfElements
{
get { return collection.Count; }
}
}
Двадцать лет строил песочный замок, потом поумнел и стал строить воздушный.
Последний раз редактировалось 04 April 2005 14:00
|
|