I am not sure how to go about this. I have a dynamic comma delimited string:
A - B, Hello, C - D, World
I need to take that string and remove/filter out all instances of items that have a ” – ” in it. So the desired result would be a new string that would look like this:
Hello, World
Now if this cannot be done using string manipulation, the string comes from a
IEnumerable<string>
using linq. So maybe there is a way to get my desired result by using LINQ.
Here is the code:
var apps = lbAppGroup.Items.Cast<ListItem>().Where(i => i.Selected).Select(i => i.Value);
string selectedAppValues = String.Join(", ", apps.ToArray());
This returns my initial example.
I am using C# 3.5. Any direction or examples would be greatly appreciated!
Just do it with LINQ like you’re already doing:
Also, you could use a regular expression like this:
But you would only do that if you only had the string.