且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

什么是子串的含义

更新时间:2022-05-22 15:15:17

SubString返回字符串的一部分,由



指定起始字符位置 - >字符串的结尾

SubString returns a part of the string, by either

specified starting character position --> the end of the string
string a = "Hello World";
string b = a.SubString(6);
Console.WriteLine(b);

output:
World



指定起始字符位置 - >指定的长度


specified starting character position --> a specified lenght

string a = "Hello World";
string b = a.SubString(0,5)
Console.WriteLine(b);

output:
Hello



http://msdn.microsoft.com/en-us/library/aka44szs(v=vs.110).aspx [ ^ ]


在使用基本的.NET对象(在这种情况下,使用String对象)时,你应该习惯去看看MSDN:

String.Substring方法 [ ^ ]



它将解释你应该知道的有关Substring()方法及其重载的所有内容。
You should take the habit to go and see MSDN when it comes to using basic .NET objects (in that case, the String object):
String.Substring Method[^]

It will explain everything you should know about the Substring() method and its overloads.


substring是一个字符串的方法,它只返回范围之间的值



substring is a method of a string it returns only the value between the range

string input = "OneTwoThree";

   
    string sub = input.Substring(0, 3);
    Console.WriteLine("Substring: {0}", sub);







结果:

一个




Result:
one

string input = "OneTwoThree";

   
    string sub = input.Substring(4, 3);
    Console.WriteLine("Substring: {0}", sub);





结果:

两个



Result:
Two

substring('yourstring',startIndex,endIndex)







更多信息