Code for Extract no from list in C#.net

Naraayanan
Posted by Naraayanan under C# category on | Points: 40 | Views : 997

private int CompareText(string fValue, string svalue)

{



string formHeading = fValue;



string userSearch = svalue;



string constring = string.Empty;



string comstring = string.Empty;



string[] formHeadingWords;



string[] userSearchWords;





formHeadingWords = System.Text.RegularExpressions.Regex.Split(formHeading, @"\W");



userSearchWords = System.Text.RegularExpressions.Regex.Split(userSearch, @"\W");



int cntFarray = formHeadingWords.Length;



int cntSarray = userSearchWords.Length;



if (cntSarray > cntFarray)

{



foreach (string _str in userSearchWords)

{

int strlength = _str.Length;

if (strlength == 1)

{

if (formHeading.Contains(_str))

{

chk = 1;

}

}

else if (strlength > 1 )

{

thechars = _str.ToCharArray();

for (int idx = 0; idx < thechars.Length; idx++)

{

if (formHeading.Contains(thechars[idx]))

{

chk = chk + 1;

}

}

}

}



}

result = chk;



return result;

}

Comments or Responses

Login to post response