Remove Duplicate value from string array - CSharp System

CSharp examples for System:Array Operation

Description

Remove Duplicate value from string array

Demo Code


using System.Text;
using System.Diagnostics;
using System.Collections.Generic;
using System;//from  ww w.  j a v  a  2  s .  c  o m

public class Main{

        public static string[] RemoveDup(string[] values)
        {
            List<string> list = new List<string>();
            for (int i = 0; i < values.Length; i++)
            {
                if (!list.Contains(values[i]))
                {
                    list.Add(values[i]);
                };
            }
            return list.ToArray();
        }
}

Related Tutorials