On Apr 7, 10:00 am, raulavi <raul...@discussions.microsoft.comwrote:
vs 2005 c#
How do I get the number of filled item from an array?
string[] myArr = {"","","",""};
myArr[0] = "one";
myArr.Length = 4;
How do I get the number of filled item from an array in this case 1.
or is any other way to define arrays as unlimited ?
Thanks
If you have VC# 2008, you can use this:
string[] myarray = { "", "", "", "" };
myarray[0] = "One";
int count = myarray.Count(s =(s != null && s != ""));
MessageBox.Show("Number of filled items: " +
count.ToString());
Although for a large array, this might not be the best way.
Chris