Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,870 questions

51,793 answers

573 users

How to computes mathematical unions (removes duplicates) on two int arrays in C#

2 Answers

0 votes
using System;
using System.Linq;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] arr1 = { 1, 2, 3, 4, 4, 5 };
            int[] arr2 = { 2, 3, 4, 6 };

            var unionArr = arr1.Union(arr2);

            foreach (int n in unionArr)
                Console.WriteLine(n);
        }
    }
}


/*
run:

1
2
3
4
5
6

*/

 



answered Feb 28, 2017 by avibootz
0 votes
using System;
using System.Linq;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] arr1 = { 'a', 'b', 'b', 'x', 'c' };
            char[] arr2 = { 'c', 'b', 'y' };

            var unionArr = arr1.Union(arr2);

            Console.WriteLine(string.Join(", ", unionArr));
        }
    }
}


/*
run:

a, b, x, c, y

*/

 



answered Feb 28, 2017 by avibootz

Related questions

3 answers 240 views
1 answer 94 views
3 answers 234 views
234 views asked Mar 14, 2017 by avibootz
2 answers 181 views
1 answer 190 views
2 answers 237 views
1 answer 127 views
...