count numbers
how we can count numbers in string array using c-sharp ?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jaish MathewsPosted Apr 11, 2010, 12:20 PM
If you are looking for count of "number items" in a ArrayString below logic will help. TryParse() is the method to use.
string[] arr1 = new string[] { "one", "two", "three", "200", "300" };
int num;
int numCount = 0;
foreach (string str in arr1)
{
if (int.TryParse(str, out num))
{
numCount = numCount + 1;
}
}