Arraylist in c#
how to get values in the arraylist from the user at run time?The user might enter string or integer.i want to get those values from the user and display?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Sep 23, 2012, 10:12 AM
object obj = arrayList[0];
if (obj.GetType() = typeof(int))
{
int myInt = (int)obj;
Console.WriteLine("An integer value, {0}, was entered first", myInt);
}
else
{
string myString = (string)obj;
Console.WriteLine("A string value, {0}, was entered first", myString);
}
Akkiraju IvaturiPosted Sep 23, 2012, 1:06 AM