C# 子字符串转到字符串末尾

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10323461/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-09 13:22:54  来源:igfitidea点击:

Substring go to End of String

c#

提问by

I am trying to get have one Substring go from the beginning of a string to a certain position and another Substring go from the end of the last position to the end of the string. But I don't know what the end will be. it will be multiple lengths. Is there a way to just go to the end of the string without giving a specific character position, something like below?

我试图让一个子字符串从字符串的开头到某个位置,另一个子字符串从最后一个位置的末尾到字符串的末尾。但我不知道结局会怎样。它将是多个长度。有没有办法只到字符串的末尾而不给出特定的字符位置,如下所示?

StartVariable.Substring(0, 14)
EndVariable.Substring(15, Substring.Length)

Thanks!

谢谢!

采纳答案by Alan

Just use EndVariable.Substring(15).

只需使用EndVariable.Substring(15).

回答by Jeppe Stig Nielsen

How about:

怎么样:

string start = input.Remove(15);
string end = input.Substring(15);

回答by Jaros?aw Maruszewski

I think it should be like:

我认为它应该是这样的:

EndVariable.Substring(14);