countLines

Summary

Counts the number of lines in the string (including empty lines).

Usage

public int countLines()

Returns

The number of lines in the string (including empty lines).

Description

Counts the number of lines in the string (including 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
import System;
 
string story =
    """
    The quick brown fox
    jumped over
    the lazy dog.
    """;
 
Console.log(story.countLines()); // 3

Share

HTML | BBCode | Direct Link