splitLines

Summary

Splits the string into individual lines and returns the resulting lines in an array.

Usage

public string[] splitLines()

Returns

An array containing each line of the original string.

Description

Splits each individual line of text into a string. The result is an array of strings with each array item representing a line of the original text.

This method handles different line endings across Windows, Mac, and Linux.

Examples

Basic Usage
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import System;
 
string story =
    """
    I jumped.
    He jumped.
    She jumped.
    """;
 
string[] lines = story.splitLines();
 
foreach(string line in lines) {
    Console.log(line);
}

Share

HTML | BBCode | Direct Link