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 JayaramanPosted Jul 28, 2012, 6:36 AM
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);
Pavi SPosted Jul 28, 2012, 6:28 AM
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 JayaramanPosted Jul 28, 2012, 5:56 AM
{
if(item!=null and item!="")
list.Add(item);
}