Silverlight / WPF - Add next line(\n) in a generic List contains more than 100 characters

Asked By gopal krish on 28-Jun-12 04:45 AM

i have a generic list contains 100 index values..

for examples

private List<string> _list=new List<string> ();

 _list.Add("The Microsoft Developer Network (MSDN) is the portion of Microsoft responsible for managing the firm's relationship with developers and testers, such as: hardware developers interested in the operating system (OS), and software developers standing on the various OS platforms or using the API and/or scripting languages of Microsoft's applications. The relationship management is situated in assorted media: web sites, newsletters, developer conferences, trade media, blogs and DVD distribution. The life cycle of the relationships ranges from legacy support through evangelizing potential offerings.");


here i need to give "\n" if the index contains more than 100 characters.

i have used the below lines 

 static IEnumerable<string> Split(string str, int chunkSize)
            return Enumerable.Range(0, str.Length / chunkSize)
                .Select(i => str.Substring(i * chunkSize, chunkSize));

  IEnumerable<string> ss = Split(_list[0].ToString(), 100);  
in the above line i need to pass my whole list values and split if any index contains more than 100 characters.
but i passed the static index value of my list. but i need to pass my whole list.

i dont waant to use for loop. is it possible to achieve this in linq..

need ur suggestions with examples...


Jitendra Faye replied to gopal krish on 29-Jun-12 12:31 AM
Use this working code-

       List<string> _list=new List<string> ();

       foreach (string str in _list)
         if (str.Length > 100)
           string s = str.Insert(100, "\n");


Try this and let me know.