Answers for "how to look for substring in string in c#"

C#
2

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 "";
    }
}
Posted by: Guest on March-24-2020
3

how to look for substring in string in c#

String phrase = "this is the ultimate string";

Console.WriteLine(phrase.Contains("this")); //returns True
Console.WriteLine(phrase.Contains("python")); //returns False
Posted by: Guest on April-29-2020

Code answers related to "how to look for substring in string in c#"

C# Answers by Framework

Browse Popular Code Answers by Language