-1

I have the following Guids received from client in an array.

Question: How i can take count of the unique Guids showing after '_' from the following array.

0: "5146d57a-701d-e511-82ee-303a64efb676_6544d57a-701d-e511-82ee-303a64efb676"
1: "5546d57a-701d-e511-82ee-303a64efb676_6544d57a-701d-e511-82ee-303a64efb676"
2: "5346d57a-701d-e511-82ee-303a64efb676_6544d57a-701d-e511-82ee-303a64efb676"

3: "5146d57a-701d-e511-82ee-303a64efb676_6644d57a-701d-e511-82ee-303a64efb676"
4: "5546d57a-701d-e511-82ee-303a64efb676_6644d57a-701d-e511-82ee-303a64efb676"
5: "5346d57a-701d-e511-82ee-303a64efb676_6644d57a-701d-e511-82ee-303a64efb676"

6: "5146d57a-701d-e511-82ee-303a64efb676_6744d57a-701d-e511-82ee-303a64efb676"
7: "5546d57a-701d-e511-82ee-303a64efb676_6744d57a-701d-e511-82ee-303a64efb676"
8: "5346d57a-701d-e511-82ee-303a64efb676_6744d57a-701d-e511-82ee-303a64efb676"
TheKingPinMirza
  • 7,924
  • 6
  • 51
  • 81

1 Answers1

2

If your input is some implementation of IEnumerable<string> (e.g. array or list):

int count = input.Select(line => line.Split('_').Last()).Distinct().Count();

This splits each line at the _ character, takes only the last part and counts the distinct parts.

Raidri
  • 17,258
  • 9
  • 62
  • 65