As long as you can put an object into array list item what do you mean by
"set the type". You can put ANY kind of object into array list like
tabs.Add(stringvalue); tabs.Add(myObject) or anything you want. If you want
to know when you get the data what kind of object do you have in ArrayList
you can use Object.GetType (i.e. tabs[index].GetType()) and it will return
you the type of the object stored in ArrayList item.
Also you can hold the type of the object (if you really need it) into the
ArrayList item by defininig a structure or a class like:
public struct ItemStruct
{
public System.Type typeOfObject;
public Object objValue;
}
and insert this structure in the ArrayList
ItemStruct mystruct = new ItemStruct();
mystruct.typeOfObject = myObject.GetType();
mystruct.objValue = myObject;
tabs.Add(mystruct);
--
Horatiu Ripa
Tamir Khason said:
How can I set the type of the object added to ArrayList (type of Array List
Members)
Here is the code:
protected ArrayList tabs = new ArrayList();
public ArrayList Tabs
{
get
{
return tabs;
}
set
{
tabs.Add(value); //The default type is object - how to change it to my
type???
}
}