Convert string to multiline text I made this method that takes any string and transforms it into a multiline text l; each line having the max (character) length specified by the rowLength parameter.

How can I make this better, functionality and code wise?

There is currently one known issue. It sometimes adds an empty line at the end because I have to add the Enviroment.NewLine call. Check it out, please, and give some suggestions. 

public static string ConvertToMultiLineText(string value, int rowLength)
{
    var multiLine = new StringBuilder();
    string[] lines = value.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
    var filterLines = lines.Where(line =&gt; !line.IsNullEmptyOrWhiteSpace());

    foreach (var line in filterLines)
    {
        if (line.IsNullEmptyOrWhiteSpace())
            continue;

        if (line.Length &gt; rowLength)
        {
            int startIndex = 0;
            var number = (decimal)line.Length / rowLength;
            var rowNumber = Math.Ceiling(number);

            for (int i = 0; i &lt; rowNumber; i++)
            {
                if (line.Contains(@" "))
                {
                    int lastIndex = rowLength;

                    // if it's not the first row set the last character on the current row of the iteration
                    if (i != 0)
                        lastIndex = (rowLength * (i + 1));

                    // if it's the last row set last character as the lenght of the last row
                    if (i == rowNumber - 1)
                        lastIndex = line.Length - 1;

                    int lastSpace = line.LastIndexOf(@" ", lastIndex, StringComparison.Ordinal);

                    //if " " is found inside the string
                    if (lastSpace &gt; -1)
                    {
                        var lastOccurence = (lastSpace &lt;= startIndex) ? startIndex - lastSpace : lastSpace - startIndex;

                        if (i == rowNumber - 1)
                            multiLine.Append(line.Substring(startIndex, lastOccurence) + Environment.NewLine + line.Substring(lastSpace, line.Length - lastSpace));
                        else
                            multiLine.Append(line.Substring(startIndex, lastOccurence) + Environment.NewLine);

                        startIndex = lastSpace;
                    }
                    else
                    {
                        if (i == rowNumber - 1)
                            multiLine.Append(line.Substring(startIndex, (line.Length - rowLength * ((int)rowNumber - 1))));
                        else
                            multiLine.Append(line.Substring(startIndex, rowLength) + Environment.NewLine);
                        startIndex += rowLength;
                    }
                }
                else
                {
                    if (i == rowNumber - 1)
                        multiLine.Append(line.Substring(startIndex, (line.Length - rowLength * ((int)rowNumber - 1))));
                    else
                        multiLine.Append(line.Substring(startIndex, rowLength) + Environment.NewLine);
                    startIndex += rowLength;
                }
            }
        }
        else
            multiLine.Append(line.Substring(0, line.Length) + Environment.NewLine);
    }

    return string.Format(@"{0}", multiLine);
}
First Impressions 
I haven't gone through the functionality in detail but a few things strike me immediately.

Why explicitly include StringSplitOptions.None. They default value is none.

IsNullEmptyOrWhiteSpace() seems to be a (not included) extension method for string that performs the same function as String.IsNullOrWhiteSpace.  Does it do something else as well?

The check for an empty 'line' inside the loop

if (line.IsNullEmptyOrWhiteSpace())
        continue;


should be redundant as we have previously filtered the lines

var filterLines = lines.Where(line =&gt; !line.IsNullEmptyOrWhiteSpace());


I would need to do up some performance checks to be sure but I reckon that the use of the StringBuilder (presumably for performance reasons) will be negated by the calls to line.SubString(). 

I can't tell for certain what the requirements are  - I would guess

Max line Length of n
Do not split words
Do not end on a space
Do not start on a space


but it look like a linear progression through the string, with some back tracking to deal with split words/spaces, might work and appending the individual chars might give you better performance.

The final return should be

return multiLine.ToString();


there is no need to create another string and place the result of multiLine.ToString() inside it and then return the anonymous string.