how to ignore spaces in list

Posted by Oswaldlily under C# on 11/26/2011 | Points: 10 | Views : 977 | Status : [Member] | Replies : 1
Column

list0->""
list1->""
list2->1
list3->""
list4->""
list5->2
list6->""
list7->""
list8->3

i need to ignore this space..
so need to get lik
list0->1
list1->2
list2->3




Responses

Posted by: Wilpeters on: 11/26/2011 [Member] Starter | Points: 25

Up
0
Down
You could run through your list and delete the empty values like this:
for(int i = list.Count;i>= 0;i--)

{
if(list[i] == "")
{
list.RemoveAt(i);
}
}


or only add strings that are not empty to your list (string x):
if(x != "")

{
list.Add(x);
}


Oswaldlily, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response