如何从文本框中将字符串或int插入到数组c# [英] How to insert string or int from textbox to array c#
本文介绍了如何从文本框中将字符串或int插入到数组c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是这样的吗?list.add(new string [] {textbox.Text});
我尝试过:
list.add(new string [] {textbox.Text});
is that like this?list.add(new string[]{textbox.Text});
What I have tried:
list.add(new string[]{textbox.Text});
推荐答案
well ,除了不知道你想要什么的问题,因为你的问题标题使用'数组',但你的代码使用'list',我现在假设'list' - 怎么样
someList.add(someTextBox.Text);
?
(这假设您已声明someList,SomeTextBox是表单上的有效TextBox)
well, apart from the issue of not knowing exactly what you want, since your question title uses 'array', yet your code uses 'list', I'll assume 'list' for now - how about
someList.add(someTextBox.Text);
?
(this assumes you have declared someList and SomeTextBox is a valid TextBox on your form)
假设您要添加对于字符串或整数列表的某些值,请检查:
Assuming that you want to add some value to a list of string or int, check this:
List<int> intList = new List<int>
intList.Add(1);
intList.Add(100);
List<string> stringList = new List<string>
stringList.Add("new string");
stringList.Add("other string");
如需了解更多信息,请参阅:列表(T)类(System.Collections.Generic) [ ^ ]
谢谢你回答我的问题。我很抱歉我错了deklare我的问题。我的意思是,如果我从文本框中添加字符串,那么c#可以做,然后字符串将写入代码。
例如:
thank you for answer my question.i am sorry i was wrong to deklare my problem.i mean Does c# can do if i adding string from textbox then the string will be write in a code.
example:
mylist.Add(new string[] {""});
当我从文本框输入banana并且我clik保存它将自动添加或更新代码。
it bec这样的话。
when i type "banana" from textbox and i clik save it will add or update automaticly from the code.
it become like this.
mylist.Add(new string[] {"banana"});
谢谢somuch。
thank you somuch.
这篇关于如何从文本框中将字符串或int插入到数组c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文