Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Help building string to add to listbox
Message
 
To
All
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
Help building string to add to listbox
Environment versions
Environment:
VB 8.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01273456
Message ID:
01273456
Views:
57
Hoping someone can guide an C# newbie. I'm looping through an array, and I want to add each element to a listbox on the form. But for each item, I want to preference it with the element name/number. I can't get past the compiler error with the code below, but if I remove the ctext="PID:" += i.ToString(); line it does add the text of the array item to the listbox.
PID:1 element 1 text
PID:2 element 2 text 
...
            string[] PID_Data = PIDString.Split(fieldSplitter);
            // Loop through each item and add to listbox
            string ctext = String.Empty;
            for(int i=0;i<PID_Data.Length;i++)
            {
                ctext = "PID: " += i.ToString();
                ctext += PID_Data[i];
                listBox1.Items.Add(ctext);
                ctext = String.Empty;
            }
Next
Reply
Map
View

Click here to load this message in the networking platform