Forum guidelines
  • Home
  • »
  • C# Language
  • »
  • In C# "Windows Form Application", How do you remove the duplicate number in an array?
AuthorQuestion
In C# "Windows Form Application", How do you remove the duplicate number in an array?
Posted By Eli on 21 Sep 2010
It has to be in Windows Form Application, not in Console Application. Please Reply. Thanks.
AuthorReply
Re: In C# "Windows Form Application", How do you remove the duplicate number in an array?
Posted By Manikavelu Velayutham on 21 Sep 2010   Accepted Answer

You can achieve this in two ways.
1. LINQ
int[] Input = { 11, 12, 13, 13,14}; 
    int[] Output = Input.Distinct().ToArray(); 

2. Looping
    public string[] DeleteDuplicates(string[] InputList) { 
       
System.Collections.ArrayList OutputList = new System.Collections.ArrayList(); 
 
       
foreach (string str in InputList) 
           
if (!OutputList.Contains(str)) 
                OutputList
.Add(str); 
       
return (string[])OutputList.ToArray(typeof(string)); 
   
} 

If you find my post helpful, Mark it as Answered or Rate the post.
Eli
  • 0
  • 0
Re: In C# "Windows Form Application", How do you remove the duplicate number in an array?
Posted By Eli on 21 Sep 2010  
Thank you for your reply.

Re: In C# "Windows Form Application", How do you remove the duplicate number in an array?
Posted By Manikavelu Velayutham on 21 Sep 2010  
if my code solves your problem please mark it as accepted
If you find my post helpful, Mark it as Answered or Rate the post.

SPONSORED BY

Custom Software Development
MCN is your source for developing solutions involving websites, mobile apps, cloud-computing, databases, BI, back-end services and processes and client-server applications.