I have an ArrayList
of email addresses. I want to remove duplicates from it.
For example my array list is:
- abc@gmail.com
- xyz@gmail.com
- abc@yahoo.com
- asd@yahoo.com
I want output like this
- abc@gmail.com
- abc@yahoo.com
I have an ArrayList
of email addresses. I want to remove duplicates from it.
For example my array list is:
- abc@gmail.com
- xyz@gmail.com
- abc@yahoo.com
- asd@yahoo.com
I want output like this
- abc@gmail.com
- abc@yahoo.com
Something like this:
ArrayList arr = new ArrayList { "abc@gmail.com", "xyz@gmail.com",
"abc@yahoo.com", "asd@yahoo.com" };
var res = arr.ToArray().GroupBy(c => c.ToString().Split('@')[1])
.Select(c=> c.FirstOrDefault()).ToArray();
I used an ArrayList
to adjust with your question, but it would be better to use a List
or Array
of string
instead.