hakdmodz
New member
- Joined
- Sep 2, 2021
- Messages
- 3
- Programming Experience
- 3-5
Hi,
I'm not sure if this is the right section for posting a help request but hopefully someone can help me out.
What is the best way to do a foreach loop to get each item from a string array and fill increasing indexed item of different string array
example and my guess as to how i figure it should be processed but without success.
// list of strings to fill each indexed item in labelsList
string[] list1 = {"blah", "blah2", "blah3", "blah4", "blah5"};
//list of labels to fill from indexed items in list1 example
string[] labelsList = {Label1.Text,Label2.Text,Label3.Text,Label4.Text,Label5.Text}
foreach (string S in list1)
{
foreach(string L in labelsList)
{
labelsList[] = s;
}
}
I want outcome to be as such for this example I have a large list of labels to fill from a large list of strings read using stream reader
Label1.Text = "blah1"
Label2.Text = "blah2"
Label3.Text = "blah3"
Label4.Text = "blah4"
Label5.Text = "blah5"
can someone please help me accomplish this in minimal code
I'm not sure if this is the right section for posting a help request but hopefully someone can help me out.
What is the best way to do a foreach loop to get each item from a string array and fill increasing indexed item of different string array
example and my guess as to how i figure it should be processed but without success.
// list of strings to fill each indexed item in labelsList
string[] list1 = {"blah", "blah2", "blah3", "blah4", "blah5"};
//list of labels to fill from indexed items in list1 example
string[] labelsList = {Label1.Text,Label2.Text,Label3.Text,Label4.Text,Label5.Text}
foreach (string S in list1)
{
foreach(string L in labelsList)
{
labelsList[] = s;
}
}
I want outcome to be as such for this example I have a large list of labels to fill from a large list of strings read using stream reader
Label1.Text = "blah1"
Label2.Text = "blah2"
Label3.Text = "blah3"
Label4.Text = "blah4"
Label5.Text = "blah5"
can someone please help me accomplish this in minimal code