Originally Posted by
licantropo
Well, I'm trying to create a app using Visual Studio 8. I'm new in the c# language...
The problem is that when I add items to a List of objects, and in the end when a do a foreach to see if everything is fine, the result is allways the same... Can anyone help me finding the "bug"?
Here is some code:
/**********************************/
List<Option> options = new List<Option>();
number=1;
do
{
Option option = new Option(number);
options.Add(option);
number++;
} while (number != 5);
foreach (Option o in options)
{
result += "\n" + o.number;
}
MessageBox.Show(result);
/*****************************/
This results in a MessageBox with:
4
4
4
4