Monday, November 28, 2011

Finding Repeated values in a String


Finding Duplicate values in String:

First Method:

string[] s1 ={ "a","a","a"};

List<string> myList1 = new List<string>();
List<string> duplicates = new List<string>();


foreach (String s in s1)
{
   if (!myList1.Contains(s))
{
      myList1.Add(s);
   }
else {
      duplicates.Add(s);
}

// show list without duplicates...

foreach (String s in myList1)
{
   Console.WriteLine(s);
}

// show duplicates list...

foreach (String s in duplicates)
{
   Console.WriteLine(s);
}
----------------------------------------------
Second Method:
int[] p = { 1, 2, 9, 9, 6};
int[] q = p.Distinct().ToArray();

amazon

Sukanya Samriddhi Account - SBI

SUKANYA SAMRIDDHI Account information by SBI SUKANYA SAMRIDDHI ACCOUNT : FACILITY AVAILABLE AT ALL BRANCHES OF SBI Sukanya Samriddhi ...