string search c# code example
Example 1: c# find where word is contained in a string
public static string getBetween(string strSource, string strStart, string strEnd)
{
int Start, End;
if (strSource.Contains(strStart) && strSource.Contains(strEnd))
{
Start = strSource.IndexOf(strStart, 0) + strStart.Length;
End = strSource.IndexOf(strEnd, Start);
return strSource.Substring(Start, End - Start);
}
else
{
return "";
}
}
Example 2: how to look for substring in string in c#
String phrase = "this is the ultimate string";
Console.WriteLine(phrase.Contains("this"));
Console.WriteLine(phrase.Contains("python"));
Example 3: search letters in list c#
The characters of the string in reverse are :
m o c . e c r u o s e r 3 w