using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
List<string> list = new List<string>();
list.Add("111");
list.Add("111");
list.Add("222");
list.Add("333");
list.Add("333");
list.Add("333");
list.Add("444");
list.Add("444");
list.Add("555");
List<string> termsList = new List<string>();
string[] numbers = list.ToArray();
int
count = 0;
int
dupcount = 0;
foreach (string s in numbers)
{
count++;
}
foreach (string s in numbers)
{
dupcount = 0;
for(int i=0; i<count; i++)
{
string checkstrng = numbers[i];
if (s == checkstrng)
{
dupcount++;
}
if (dupcount > 1)
{
bool
bdupchk = termsList.Contains(s);
if (bdupchk == false)
{
termsList.Add(s);
}
dupcount = 0;
}
}
}
string[] terms = termsList.ToArray();
foreach(string result in terms)
Console.WriteLine(result);
}
Console.Read();
}
}
}
Output:
111
333
444
No comments:
Post a Comment