countNonEmptyLines

Summary

Counts the number of non-empty lines in the string.

Usage

public int countNonEmptyLines()

Returns

The number of non-empty lines in the string.

Description

Counts the number of non-empty lines in the string. Only empty strings count as empty lines (""). Strings with whitespace do not count as empty lines.

Please note that this method's return value will overflow and wrap if it exceeds System.Integer32.MAX_VALUE.

Examples

Basic Usage
1
2
3
4
5
6
7
8
9
10
11
12
13
import System;
 
string story =
    """
    The quick brown fox
 
    jumped over
 
    the lazy dog.
    """;
 
Console.log(story.countLines()); // 5
Console.log(story.countNonEmptyLines()); // 3

Share

HTML | BBCode | Direct Link