arrays - Visual C# converting custom IEnumerable to string[] -


i writing plugin code in c# , there custom ienumerable in fact array of strings. no string operations can done on array elements because not of type <string>. need them strings , have operate on them strings.

so have added these 2 lines of code turn array string:

var arrayrawsourcetext = editorcontroller.activedocument.activesegmentpair.source.allsubitems.toarray(); string[] arraysourcetext = new string[arrayrawsourcetext.length]; (int = 0; < arrayrawsourcetext.length; i++) { arraysourcetext[i] = arrayrawsourcetext[i].tostring(); } 

only 2 lines, yet wonder if there simpler way of converting array <string>. lambda expression or other way make simpler.

if allsubitems implement ienumerable guess code snippet should work :

var arraysourcetext = editorcontroller.activedocument                                       .activesegmentpair                                       .source                                       .allsubitems                                       .select(t => t.tostring())                                       .toarray(); 

Comments

Popular posts from this blog

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -