how to look for substring in string in c#
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 "";
}
}String phrase = "this is the ultimate string";
Console.WriteLine(phrase.Contains("this")); //returns True
Console.WriteLine(phrase.Contains("python")); //returns False
Also in C#:
- instantiate object in circle
- when do i need to end a sentence with ; in c#
- c# string array
- socket in c#
- how to convert iformfile to byte array c#
- choose random gameobject from a gameobject list
- for c#
- c# remove time in datetime
- c# switct case
- change canvas color uwp c#
- odbc command parameters c#
- unity add component
- unity how to get y value
- how to reference scripts in other scenes unity
- c# trigger destructor
- unity get number of child objects
- c# remove specific character from string
- switch case c# contains
- .net core cli
- c# stop loop in method
- lista generica como parametro de un metodo en c#
- double to int c#
- c# constructor
- c# tostring mmm dd yyyy