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
Post a Comment