Count of Matching of between two strings??

Sabarimahesh
Posted by Sabarimahesh under C# category on | Points: 40 | Views : 1999
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication3
{
public static class Program
{

static void Main(string[] args)
{
string s = "ab";
int i = s.Comparetwo("ab"); // 2
Console.WriteLine(i);
Console.ReadLine();
}
public static int Comparetwo(this string indivi, string Tr)
{
int sm = 0, len = indivi.Length < Tr.Length
? indivi.Length : Tr.Length;
for (int i = 0; i < len; i++)
if (indivi[i] == Tr[i]) sm++;
return sm;
}


}
}

Comments or Responses

Login to post response