加入其余的字符串数组

Vik*_*ren 1 c# arrays join substring

private static string SetValue(string input, string reference)
{
    string[] sentence = input.Split(' ');
    for(int word = 0; word<sentence.Length; word++)
    {
        if (sentence[word].Equals(reference, StringComparison.OrdinalIgnoreCase))
        {
            return String.Join(" ", sentence.subarray(word+1,sentence.Length))
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

如何sentence.subarray(word+1,sentence.Length)轻松完成或以其他方式完成此操作?

Raw*_*ing 5

String.Join一个专门为此过载:

return String.Join(" ", sentence, word + 1, sentence.Length - (word + 1));
Run Code Online (Sandbox Code Playgroud)