C# C中的字符串操作。在单词之间插入“+”

C# C中的字符串操作。在单词之间插入“+”,c#,string,C#,String,这是我所能做到的。我的想法是将字符串填充到一个数组中,格式化它并将其重新转换为字符串 //input search term Console.WriteLine("What is your search query?:"); string searchTerm = Console.ReadLine(); //stuff the search term into an array to split it out string separator = " "

这是我所能做到的。我的想法是将字符串填充到一个数组中,格式化它并将其重新转换为字符串

    //input search term
    Console.WriteLine("What is your search query?:");
    string searchTerm = Console.ReadLine();

    //stuff the search term into an array to split it out
    string separator = " "; //assumes search terms are separated by spaces
    string[] searchTermArray = searchTerm.Split(separator.ToCharArray());

    //construct the search term
    string searchTermFormat = "";

    for (int i = 0; i < searchTermArray.Length; i++)
    {
        searchTermFormat += searchTermArray[i] + "+";
        //Console.WriteLine(searchTermFormat);
    }
字数不固定的地方

您正在查找String.Join+,searchTermArray 您正在尝试编写searchTerm。请替换“”,“+” 你可能应该写信
尝试string.Replace,+

这是一个典型的字符串。Replace job或RegEx

那么myString呢。Replace“”,“+”

使用字符串。Join将字符串连接在一起。

澄清:您的输入是什么样子的?它只是一个字符串,像word1 word2 word3,一个数组吗??
word1+word2+word3