I am a C# beginner.I've some problem with this exercise.Can you give me some advise?Because I've no ide what should i do.
ArrayList arrayList = new ArrayList();
Console.Write("Enter code:");
arrayList.Add(Console.ReadLine());
Console.Write("Enter qty:");
arrayList.Add(Convert.ToInt32(Console.ReadLine()));
Console.Write("Enter code:");
arrayList.Add(Console.ReadLine());
Console.Write("Enter qty:");
arrayList.Add(Convert.ToInt32(Console.ReadLine()));
ArrayList looplist = new ArrayList(arrayList);
foreach (object text in looplist)
{
if (Convert.ToString(text) == "p")
{
arrayList.RemoveAt(0);
arrayList.Insert(0, "Programming");
}
else
{
arrayList.RemoveAt(2);
arrayList.Insert(2, "Graphic");
}
Console.WriteLine("{0}", text);
}
Loading
VulpesPosted Nov 20, 2013, 5:01 AM
The output is:
So you've changed arrayList but not the copy you made from it, looplist.
moe satPosted Nov 19, 2013, 10:40 PM
my output is:
p
5
g
5
not change to "Programming" and Graphic??
VulpesPosted Nov 19, 2013, 4:31 AM
Remember that it's arrayList you're changing, not the copy looplist.