Используем StringCollection из простраства имен System.Collection.Specialized, который поддерживает интерфейсы IList, ICollection, IEnumerable
- StringCollection GetLinesCollectionFromTextBox(TextBox textBox)
- {
- StringCollection lines = new StringCollection();
-
- // lineCount may be -1 if TextBox layout info is not up-to-date.
- int lineCount = textBox.LineCount;
-
- for (int line = 0; line < lineCount; line++)
- // GetLineText takes a zero-based line index.
- lines.Add(textBox.GetLineText(line));
-
- return lines;
- }
* This source code was highlighted with Source Code Highlighter.