我有一个字符串,我想从中删除前三个字符。我该如何使用子字符串来解决这个问题,或者还有其他方法吗?
string temp = "01_Barnsley"
string textIWant = "Barnsley"
谢谢
最佳答案
您可以使用 String.Substring(Int32)
method .
Retrieves a substring from this instance. The substring starts at a specified character position and continues to the end of the string.
string textIWant = temp.Substring(3);
这是一个 demonstration
.
作为替代方案,您可以使用 String.Remove method(Int32, Int32)
method还有。
Returns a new string in which a specified number of characters in the current instance beginning at a specified position have been deleted.
string textIWant = temp.Remove(0, 3);
这是一个 demonstration
.
关于C# 子串 : Removing first three characters,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21909132/