gpt4 book ai didi

c# - 加入其余的字符串数组

转载 作者:太空宇宙 更新时间:2023-11-03 18:36:16 24 4
gpt4 key购买 nike

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.Joinan overload专门为此:

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

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

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com