A Sub-string Extractor with Specific Keywords Parameter Implementation in C#

I am trying to implement a sub-string extractor with “start keyword” and “end keyword” and the extracted result is from (but excluded) the given start keyword to (but excluded) end keyword. For example:

Input String Start Keyword End Keyword Output
“C# was developed around 2000 by Microsoft as part of its .NET initiative” “”(empty string) “”(empty string) “C# was developed around 2000 by Microsoft as part of its .NET initiative”
“C# was developed around 2000 by Microsoft as part of its .NET initiative” “”(empty string) “.NET” “C# was developed around 2000 by Microsoft as part of its”
“C# was developed around 2000 by Microsoft as part of its .NET initiative” “C#” “”(empty string) “was developed around 2000 by Microsoft as part of its .NET initiative”
“C# was developed around 2000 by Microsoft as part of its .NET initiative” “C#” “.NET” “was developed around 2000 by Microsoft as part of its”
“C# was developed around 2000 by Microsoft as part of its .NET initiative” “.NET” “”(empty string) “initiative”
“C# was developed around 2000 by Microsoft as part of its .NET initiative” “”(empty string) “C#” “”(empty string)
“C# was developed around 2000 by Microsoft as part of its .NET initiative” “.NET” “C#” “”(empty string)

The experimental implementation

The experimental implementation is as below.

private static string GetTargetString(string stringInput, string startKeywordInput, string endKeywordInput)
{
    int startIndex;
    if (String.IsNullOrEmpty(startKeywordInput))
    {
        startIndex = 0;
    }
    else 
    {
        if (stringInput.IndexOf(startKeywordInput) >= 0)
        {
            startIndex = stringInput.IndexOf(startKeywordInput) + startKeywordInput.Length;
        }
        else
        {
            return "";
        }
        
    }

    int endIndex;
    if (String.IsNullOrEmpty(endKeywordInput))
    {
        endIndex = stringInput.Length;
    }
    else
    {
        if (stringInput.IndexOf(endKeywordInput) > startIndex)
        {
            endIndex = stringInput.IndexOf(endKeywordInput);
        }
        else
        {
            return "";
        }
    }
    
    
    //    Check startIndex and endIndex
    if (startIndex < 0 || endIndex < 0 || startIndex >= endIndex)
    {
        return "";
    }

    if (endIndex.Equals(0).Equals(true))
    {
        endIndex = stringInput.Length;
    }
    int TargetStringLength = endIndex - startIndex;
    return stringInput.Substring(startIndex, TargetStringLength).Trim();
}

Test cases

string test_string1 = "C# was developed around 2000 by Microsoft as part of its .NET initiative";

Console.WriteLine(GetTargetString(test_string1, "", ""));
Console.WriteLine(GetTargetString(test_string1, "", ".NET"));
Console.WriteLine(GetTargetString(test_string1, "C#", ""));
Console.WriteLine(GetTargetString(test_string1, "C#", ".NET"));
Console.WriteLine(GetTargetString(test_string1, ".NET", ""));
Console.WriteLine(GetTargetString(test_string1, "", "C#"));
Console.WriteLine(GetTargetString(test_string1, ".NET", "C#"));

The output of the above test cases.

C# was developed around 2000 by Microsoft as part of its .NET initiative
C# was developed around 2000 by Microsoft as part of its
was developed around 2000 by Microsoft as part of its .NET initiative
was developed around 2000 by Microsoft as part of its
initiative


If there is any possible improvement, please let me know.