JElster
asked on
C# - How to remove duplicates from a string
Hi..
I have a string of email addreses with duplicates like this.
How can I remove the dups.. maybe use Split and LINQ?
"jon@abc.com; mary@xyz.com ; jon@ABC.com; MARY@xyZ.com"
I want to return
"jon@abc.com; mary@xyz.com"
thx
I have a string of email addreses with duplicates like this.
How can I remove the dups.. maybe use Split and LINQ?
"jon@abc.com; mary@xyz.com ; jon@ABC.com; MARY@xyZ.com"
I want to return
"jon@abc.com; mary@xyz.com"
thx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You have to convert to lowercase as per my example, otherwise it's not going to trim out the case differences.
Yes, in my code just add a ".ToLower" right inbetween "yourEmailList" and "Split". Thanks Snarf.
string[] emails = yourEmailList.ToLower.Split(';');