使用while循环从字符串的开头删除空格
我做了什么。当我在纸上浏览这种算法时,这是有道理的...我在哪里错了?我无法使用Trim方法,因为该任务是使用一个while循环 我知道我有点愚蠢,因为我无法弄清楚这项最简单的任务,但是请您提前感谢任何会解释这件事的人!
public static string RemoveStartSpaces(string text)
{
int i = 0;
while (char.IsWhiteSpace(text[i]))
{
i++;
text.Substring(i);
}
return text;
}
i did something. when i go through this algorithm on a paper, it makes sense... where am i wrong? i can't use trim method because the task is to use a while loop
i know i'm kinda stupid 'cause i can't figure out this simplest task, but thank you in advance to anyone who'll explain this thing!
public static string RemoveStartSpaces(string text)
{
int i = 0;
while (char.IsWhiteSpace(text[i]))
{
i++;
text.Substring(i);
}
return text;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论