static void Main(string[] args)
{
string s = "ABCDEFGH";
string newS = ShiftString(s);
Console.WriteLine(newS);
}
public static string ShiftString(string t)
{
char[] c = t.ToCharArray();
char save = c[0];
for (int i = 0; i < c.Length; i++)
{
if (c[i] != c[0])
c[i] = c[i - 1];
}
Console.WriteLine(c);
String s = new string(c);
return s;
}
Run Code Online (Sandbox Code Playgroud)
我需要将字符串s向左移动一个空格,所以我最终得到了字符串:"BCDEFGHA"所以我想将字符串更改为char数组并从那里开始工作,但我不知道如何成功制作这项工作.我很确定我需要一个for循环,但我需要一些帮助来解决如何将char序列向左移动一个空格.