Form string
I need to form a string for a loop. I am getting one value in the "name" variable. Now do I need all the value in the namevalues variable? on the list with Peter, John, Joseph.
How can i do this?
for (int i = 0; i < 2; i++)
{
string name = Listboxs.Items[i].ToString();
string namevalues = ??;
}
Expected Output is : Pieter*John*Joseph
+3
source to share
3 answers
Use string.Join
withCast()
var namevalues = string.Join("*", Listboxs.Items.Cast<string>().ToArray());
0
source to share