C# 子字符串:删除前三个字符 [英] C# substrings: Removing first three characters
问题描述
我有一个字符串,我想从中删除前三个字符.我如何使用子字符串来解决这个问题,或者还有其他方法吗?
I have a string which I would like to remove the first three characters from. How do I go about this using substrings, or is there any other way?
string temp = "01_Barnsley"
string textIWant = "Barnsley"
谢谢
推荐答案
您可以使用 String.Substring(Int32)
方法.
You can use 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);
这是一个演示
.
作为替代,您可以使用 String.Remove method(Int32, Int32)
method 也是.
As an alternative, you can use String.Remove method(Int32, Int32)
method also.
返回一个新字符串,其中包含指定数量的字符从指定位置开始的当前实例已被删除.
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);
这是一个演示
.
这篇关于C# 子字符串:删除前三个字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!