ExtensionMethod.NET Home of 880 C#, Visual Basic, F# and Javascript extension methods

CountNonEmptyItemsInStringArray

Method returns the number of non-null or non-empty items wihtin a string array of length n.

Source

int n= src.Count( p => String.IsNullOrEmpty( p ) == false );

Example

int len = 10;
string[] src = new string[len];

src[5]="some text";

// count non-null or non-empty items within src-arry
int n= src.Count( p => String.IsNullOrEmpty( p ) == false );

// n should return 1;

Author: rishka

Submitted on: 21 jan. 2009

Language: C#

Type: System.String

Views: 3915