multiple lines string
-
i have to check if my string span to more than one lines than append space at start of each line..hw can this be done? Regards Ali
-
i have to check if my string span to more than one lines than append space at start of each line..hw can this be done? Regards Ali
It would be great if you give some example so that I can give you proper solution. Thanks !
Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.
-
It would be great if you give some example so that I can give you proper solution. Thanks !
Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.
dr[i - 1] = " " + fieldValues[i].ToString(); this is my code...it only appends space at first line of string but if string spans multiple lines hw to append space at start of each line.
-
dr[i - 1] = " " + fieldValues[i].ToString(); this is my code...it only appends space at first line of string but if string spans multiple lines hw to append space at start of each line.
You have to split the original string at new lines, add the space and then Join them together again. This is an example:
string original = ...;
string spaced = String.Join( "\n", original.Split( '\n' ).Select( s => " " + s ).ToArray() );
Nick
---------------------------------- Be excellent to each other :)
-
dr[i - 1] = " " + fieldValues[i].ToString(); this is my code...it only appends space at first line of string but if string spans multiple lines hw to append space at start of each line.
dr[i - 1] = " " + fieldValues[i].Replace("\n","\n ");
--EricDV Sig--------- Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peters