my code
---------
string[] array = new string[] { "a", "", null, "d" };
List
foreach (string item in array)
list.Add(item);
actual o/p is
----------------
list[0]="a"
list[1]=""
list[2]=null
list[3]="d"
i want like this
----------------
list[0]=a
list[1]=d
how to restrict null or empty entries adding in the list. please anyone help me.

Santhosh Kumar JayaramanRank #563 · 4.3K reputationPosted Jul 28, 2012, 1:56 AM EDT
{
if(item!=null and item!="")
list.Add(item);
}
Pavi S36 reputationPosted Jul 28, 2012, 2:28 AM EDT
this.FirstValue = this.textBox1.Text;
this.SecondValue = this.textBox2.Text;
this.ThirdValue = this.textBox3.Text;
names.Add(FirstValue); // value =one
names.Add(SecondValue);//value =two
names.Add(ThirdValue);//value =null
string text=string.Join (":",names);
i want output like this
text value is one:two not one:two:
Santhosh Kumar JayaramanRank #563 · 4.3K reputationPosted Jul 28, 2012, 2:36 AM EDT
this.SecondValue = this.textBox2.Text;
this.ThirdValue = this.textBox3.Text;
names.Add(FirstValue); // value =one
names.Add(SecondValue);//value =two
names.Add(ThirdValue);//value =null
List
foreach (string item in names)
{
if(item!=null and item!="")
newlist.Add(item);
}
string text=string.Join (":",newlist);