110,549
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace ListRead
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private List<StructTest> poList = null;
private void button1_Click(object sender, EventArgs e)
{
poList = new List<StructTest>();
for (int i = 0; i < 3; i++)
{
StructTest oTemp = new StructTest();
oTemp.Str1 = "AA";
oTemp.Str2 = "AA";
poList.Add(oTemp);
}
}
private void button2_Click(object sender, EventArgs e)
{
for (int i = 0; i < poList.Count; i++)
{
poList[i].Str1 = "BB";
poList[i].Str2 = "BB";
}
}
public struct StructTest
{
public string Str1;
public string Str2;
}
}
}
StructTest st = poList[i];
st.Str1 = "BB";
st.Str2 = "BB";