从文本框中捕获一定数量的字符。 [英] Capture a certain number of characters from text box.
问题描述
嗨再次,
我希望我的文本框将其中的文本分解为不同的变量。例如,如果我将3000个字符的文本粘贴到文本框中,我希望前几千个到var = text1,第二个千个到var = text2等...
我现在使用以下代码将所有文本保存到变量:
public void button1_Click(object sender,EventArgs e)
{
var list = textBox1.Text;
}
我想的一种方法是捕获前1000个字符,将它们保存到var然后删除它们。然后循环直到所有文本消失。
还有其他方法吗?
提前致谢。
使用 String.Substring方法(Int32,Int32) [ ^ ]。
[Agent_Spock]
您的案例示例: -
var list = textBox1.Text.Substring(0,1000);
这会给你前1000个字母和第二个一千个使用
var list = textBox1.Text.Substring(1000,1000);
Hi again,
I want my text boxes to break down the text within them into different variables. For example, if I paste 3000 characters of text into the text box I want the first thousands to var = text1, the second thousand to var = text2 etc...
I use the following code to save all the text to a variable at the moment:
public void button1_Click(object sender, EventArgs e)
{
var list = textBox1.Text;
}
One method I was thinking was to capture the first 1000 characters, save them to a var and then delete them. Then just loop that until all the text is gone.
Any other methods?
Thanks in advance.
Use String.Substring Method (Int32, Int32)[^].
[Agent_Spock]
Example in your case:-
var list = textBox1.Text.Substring(0,1000);
This would give you first 1000 letters and for second one thousand use
var list = textBox1.Text.Substring(1000,1000);
这篇关于从文本框中捕获一定数量的字符。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!