-
July 1st, 2009, 08:58 PM
#1
List of objects
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
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|