3

初学者咨询一个 C#的问题,求大佬解答啊

 1 year ago
source link: https://www.v2ex.com/t/938154
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

V2EX  ›  C#

初学者咨询一个 C#的问题,求大佬解答啊

  buxiugangpen · 4 小时 32 分钟前 · 520 次点击
我需要创建一个结构体
struct jiegouti
{
public string data_bj;
public string data_bx;
public string data_tx;
public string data_ty;
}
现在想根据页面数据的数量来自动创建多个结构体,比如
jiegouti jgt1;
jiegouti jgt2;
jiegouti jgt3;
jiegouti jgt4;

这些结构体要获取类似的控件数据
比如下面的
jgt1.data_bj = txbox_bj1.Text;
jgt1.data_bx = txbox_bx1.Text;
jgt1.data_tx = txbox_tx1.Text;
jgt1.data_ty = txbox_ty1.Text;

jgt2.data_bj = txbox_bj2.Text;
jgt2.data_bx = txbox_bx2.Text;
jgt2.data_tx = txbox_tx2.Text;
jgt2.data_ty = txbox_ty2.Text;

我现在想要写个循环,来根据页面的数量自动创建结构体,并且获取每个结构体字段下面的控件数值,应该怎么写,我写出来的结构体中的局部变量都变成字符串了,,
我的大概写法,如下,求大佬帮忙看看咋弄。
for(int j=1;j<=6;j++){
$["jgt"+j].data_bj = $["txbox_bj"+j].Text
}

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK