I am looking for a solution I have several TexBoxes I would like to get the information when there is some and insert them in a label with a "," between each. I had thought of a solution with Foreeach :
List<TextBox> test = new List<TextBox>() { Test1, Test2, Test3, Test4, Test5, Test6 };
if (test != null)
{
test .ForEach(("," + Result.Content.ToString());
}
But he not work. any body for help me please ?
Use Join to join the strings and some linq
var ls = new List<TextBox>()
{
new TextBox() { Text = "test1" },
new TextBox() { Text = "test2" },
new TextBox() { Text = "test3" }
};
var concat = string.Join(",", ls.Select(x=>x.Text));
Console.WriteLine(concat);