O
O
OuTsider_012018-11-12 18:04:26
C++ / C#
OuTsider_01, 2018-11-12 18:04:26

Removing duplicate elements from an array?

string[] a = Console.ReadLine().Split(' ');
string[] b = Console.ReadLine().Split(' ');
string[] z = new string[a.Length + b.Length];
a.CopyTo(z, 0);
b.CopyTo(z, a.Length);
How to remove duplicate elements from z array? Help pls:c

Answer the question

In order to leave comments, you need to log in

1 answer(s)
#
#, 2018-11-12
@OuTsider_01

R82n3Ex.png
ps List is essentially a dynamic array, in many cases it is more convenient. Distinct() returns an IEnumerable. if you need a strictly array output, everything is also simple - var uniques = ls.Distinct().ToArray();List, IEnumerable and Array are mutually convertible in any combination. and for all there is a Distinct() extension

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question