Split String into smaller words by length variable in c# : <p>Hi I have a string paragraph containing 25 words and 300 characters, I want to set it in set of labels which can be contain 40 characters. I am trying it as below code with character lengths.</p>

<pre><code>public static List&lt;string&gt; _mSplitByLength(this string str, int maxLength)
{
    List&lt;string&gt; _a = new List&lt;string&gt;();
    for (int index = 0; index &lt; str.Length; index += maxLength)
    {
        _a.Add(str.Substring(index, Math.Min(maxLength, str.Length - index)));
    }
    return _a;
}
</code></pre>

<p>with above code i can split string into 40 character but problem is that it split words also.</p>

<p>suppose my string is <code>"My school Name is stack over flow High school."</code> which is 46 characters so with my code its getting like this</p>

<pre><code>list 1 = "My school Name is stack over flow High s"
list 2 = "chool."
</code></pre>

<p>My question is how to split string on basis of words. if last word not comming so it should be transfer to next list.</p>

<p>my Aim is </p>

<pre><code>list 1 = "My school Name is stack over flow High "
list 2 = "school."
</code></pre>
