-3

The below example splits two strings of codes and appends them together. The problem is it doesn't filter duplicates. In this case allCodes has "DL" twice. Is there a way to do the split & concatenate without dups?

        string carCodes = "DL, UL, AL, ";
        string airCodes = "RL, DL";

        string[] allCodes = airCodes
          .Replace(" ", "")
          .Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
          .Concat(carCodes
             .Replace(" ", "")
             .Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
          .ToArray();
Dmitry Bychenko
  • 180,369
  • 20
  • 160
  • 215
Dustin
  • 23
  • 5

1 Answers1

1

A distinct does it.

.Distinct().ToArray();
Dustin
  • 23
  • 5