开发者

.Net Linq - Doing a operation on the subset

I need to ha开发者_如何学Gove the following : (name1 + "a") + (name2 + "a") + ...

Dim separator() As String = {"|"}    
myString.Split(separator, StringSplitOptions.None).SomeLinq(...)

I don't know what to add at the end to add an "a" to each element...


Use Select in this case:

Dim separator() As String = {"|"}    
myString.Split(separator, StringSplitOptions.None).Select(Function(s) (s + "a"))

Select can be used as a "conversion" function this way, too. After this, you can convert back to your one string:

String.Join("|", myString.Split(separator, StringSplitOptions.None).Select(Function(s) (s + "a")).ToArray())

My apologies if the VB.Net is slightly off; I'm a C# developer, typically.


User StringBuilder and foreach()

EDIT: OOps, I don't know VB.NET, only C#, so use whatever the equivalent is of foreach

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜