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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Akkiraju IvaturiRank #473 · 5.3K reputationPosted Sep 22, 2012, 9:06 PM EDT
VulpesRank #55 · 29.2K reputationPosted Sep 23, 2012, 6:12 AM EDT
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);
}