foreach statement (get string values)
Posted
by nhoyti
on Stack Overflow
See other posts from Stack Overflow
or by nhoyti
Published on 2010-06-14T09:14:17Z
Indexed on
2010/06/14
9:22 UTC
Read the original article
Hit count: 110
Can someone please help me out? My code for splitting the strings is working however, i still need to use the splitted string my page. How can i achieve this? Here's my current code
private void SplitStrings()
{
List<string> listvalues = new List<string>();
listvalues = (List<string>)Session["mylist"];
string[] strvalues = listvalues.ToArray();
if (listvalues != null)
{
foreach (string strElement in listvalues)
{
string[] prods = strElement.ToString().Split("|".ToCharArray());
string prodName = prods[0].ToString();
Response.Write(prodName);
}
}
}
how can i replace the response.write with any label or literal? when i tried to use a literal on the code it displays one single string not all of the strings that's been splitted.
any ideas?
© Stack Overflow or respective owner