什么是子串的含义 [英] whats the meaning of substring
本文介绍了什么是子串的含义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在c#中,我正在创建一个计算器。现在,我刚刚在这里阅读了一个论坛,并获得了退格按钮的代码。现在,它为我工作。
我想知道什么是
In c# , i am creating a calculator. Now, i just read one of the forum here and got this code for "backspace" button. Now, its working for me.
I want to know whats the meaning of
textBox1.Text.Substring(0, i - 1)
int i = textBox1.Text.Length;
textBox1.Text = textBox1.Text.Substring(0, i - 1);
推荐答案
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)
这篇关于什么是子串的含义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文