如何使用Split()重构此C#代码?

Edw*_*uay 0 c# string refactoring

我怎样才能重构这一点,以便numberOfItems不必被声明为变量?

//method: gets the text in a string in front of a marker, if marker is not there, then return empty string
//example: GetTextAfterMarker("documents/jan/letter043.doc","/") returns "letter043.doc"
//example: GetTextAfterMarker("letter043.doc","/") returns ""
//example: GetTextAfterMarker("letter043.doc",".") returns "doc"
public static string GetTextAfterMarker(string line, string marker)
{
    int numberOfItems = line.Split(new string[] { marker }, StringSplitOptions.None).Count();

    string result = line.Split(new string[] { marker }, StringSplitOptions.None)[numberOfItems-1];
    return line.Equals(result) ? string.Empty : result;
}
Run Code Online (Sandbox Code Playgroud)

Ant*_*hyy 7

var    index = line.LastIndexOf (marker) ;
return index < 0 ? string.Empty : line.Substring (index + marker.Length) ;
Run Code Online (Sandbox Code Playgroud)