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))
        }
    }
}


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

最佳答案

String.Join为此专门具有an overload

return String.Join(" ", sentence, word + 1, sentence.Length - (word + 1));

关于c# - 连接其余的字符串数组,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14934518/

10-11 21:57
查看更多