.net - How to Join multiline strings from left to right -


i have array 3 entries.

first entry of array multiline string:

"my dog             " 

second entry too:

" dont                " 

and hird entry too:

" ...         die!     " 

now how can combine multiline strings obtain joined string left right this?:

my dog dont that...        die! 

what tried:

richtextbox1.text = string.join(myarray(1), myarray(2)) 

well example more reallistic, need combine multiline strings (which ascii letters) stored in array, when try join obtain string joined down:

enter image description here

the code i've used :

richtextbox1.text = string.join(" ", characters(70), characters(77), characters(70), characters(76)) 

this should need. key creating list of lists , splitting on newline character on each item in original array.

this should work arbitrary number of strings, each string must have same number of newline characters break on.

for example:

"yo \ndon't kill \nman!" "dude! \nme bro!       " 

this cause exception because second line has 1 \n

to fix second line changed to:

"yo \ndon't kill \nman!" "dude! \nme bro!     \n" 

this should give proper formatting.

in vb:

imports system.text module module1      sub main()         dim items list(of string) = new list(of string)()         items.add("my dog\nyou")         items.add(" dont that\n")         items.add(" ...       \n die!")         dim list list(of list(of string)) = new list(of list(of string))         dim arg() string = {"\n"}         each listitem string in items             list.add(listitem.split(arg, stringsplitoptions.none).tolist())         next          dim sb stringbuilder = new stringbuilder()          integer = 0 list(0).count - 1             j integer = 0 list.count - 1                 sb.append(list(j)(i))             next             sb.append(environment.newline)         next          console.writeline(sb.tostring())         console.readkey()     end sub end module 

and c# (my preference, it's :) ):

namespace consoleapplication1 {     class program     {         static void main(string[] args)         {             list<string> items = new list<string>();             items.add("my dog\nyou");             items.add(" dont that\n");             items.add(" ...       \n die!");             list<list<string>> list = new list<list<string>>();             items.foreach(f => list.add(f.split('\n').tolist()));             stringbuilder sb = new stringbuilder();              (int = 0; < list[0].count; i++)             {                 (int j = 0; j < list.count; j++)                 {                     sb.append(list[j][i]);                 }                 sb.append(environment.newline);             }              console.writeline(sb.tostring());             console.readkey();         }     } } 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -