TextUtility.SplitLines Method
- Namespace
- Kampute.DocToolkit.Support
- Assembly
- Kampute.DocToolkit.dll
Definition
Enumerates lines of text, splitting the input string into lines based on a specified maximum line width.
public static IEnumerable<string> SplitLines(string text, int maxLineWidth, bool preserveLineBreaks = false)Parameters
textstring- The text to split into lines.
maxLineWidthint- The maximum width of each line.
preserveLineBreaksbool optional- Indicates whether to preserve existing line breaks in the text.
Returns
- IEnumerable<string>
- An enumerable of strings, each representing a line of text.
Exceptions
- ArgumentOutOfRangeException
- Thrown when
maxLineWidthis less than or equal to zero.

preserveLineBreaksis set totrue, it will respect existing line breaks in the text. Otherwise, it will treat the entire text as a single block and wrap it according to the specified width.This method is implemented by using deferred execution. The immediate return value is an object that stores all the information that is required to perform the action.