StringCollection type represents a collection of strings. The type is part of the namespace - System.Collections.Specialized. import the namespace in your code file:
using System.Collections.Specialized;
private StringCollection GetTextLines() { var lines = new StringCollection(); int lineCount = txtPlainTxt.LineCount; for (int line = 0; line < lineCount; line++) lines.Add(txtPlainTxt.GetLineText(line)); return lines; }
The usage is straightforward as below:
Please note that each item of the StringCollection is a string holding each line of the TextBox.
// Usage var lines = GetTextLines(); foreach (var line in lines) { // line is string with each line. }
No comments:
Post a Comment