Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all,

I have array like
C#
root_result.MainDashboard[0]. 
in this array
C#
root_result.MainDashboard[0]
having some elements, how to find number of elements in this index?


example:
C#
root_result.MainDashboard[0].One,root_result.MainDashboard[0].Two,root_result.MainDashboard[0].Three,root_result.MainDashboard[0].Four
..etc.

how to count number of element in an this array index?

thanks in advance...
Posted

Here is the answer for string array:
string[] intArray = new string[10];
intArray[0] = "One";
intArray[1] = "Two";
intArray[2] = "Three";

int result = intArray.Count(i => (!String.IsNullOrEmpty(i) && i.Length > 1));
 
Share this answer
 
Comments
Member 10434230 18-Dec-13 4:28am    
Did this solved your problem?
Bojjaiah 18-Dec-13 4:37am    
yah!.. thank you...
:)
Use some thing like this:
int?[] intArray = new int?[10];
intArray[0] = 34;
intArray[1] = 65;
intArray[2] = 98;

int result = intArray.Count(i => i.HasValue);
 
Share this answer
 
Comments
Bojjaiah 18-Dec-13 1:59am    
hi,
string[] intArray = new string[10];
intArray[0] = "One";
intArray[1] = "Two";
intArray[2] = "Three";
how can I count this?
if your array is root_result.MainDashboard
and it's total index is

int totalIndex=root_result.MainDashboard.Length;

array-length[^]
count-array[^]
 
Share this answer
 
Comments
Bojjaiah 18-Dec-13 1:54am    
hello parids,
see my question clearly, I'm counting the index of array not array count!...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900