public static class TextSetting
{
   public static string[] Wrap(this string text, int max)
  {
      var charCount = 0;
      var lines = text.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
      return lines.GroupBy(w => (charCount += (((charCount % max) + w.Length + 1 >= max) ? max - (charCount % max) : 0) + w.Length + 1) / max).Select(g => string.Join(" ", g.ToArray())).ToArray();
  }

}

 

Description

  1. The above coding used to make a limit numbers of word in one line 
  2. This coding normally used to create an essay or paragraph internally
  3. Method to used it, put this coding in side class form and call it when need.

 

 

 

 

 

 

One thought on “Limit the length of word for each line

  1. I just want to tell you that I am just very new to blogging and site-building and absolutely enjoyed your web page. Most likely I’m want to bookmark your blog . You surely have fantastic articles and reviews. Kudos for sharing with us your web-site.

Leave a Reply