请明白人给讲一讲
在看别人写的代码。以下的段落中有两处不太明白,请明白人给讲一讲。
1. 声明DEVICEINFO结构时必须用public关键字吗?
2. 删除时采用的委托部分看不太懂。
struct DEVICEINFO
{
public int nDeviceID;
public string strModel;
public string strIpAddress;
public int nPort;
public string strId;
public string strPasswd;
public int hDevice;
public int hMediaSource;
}
private List<DEVICEINFO> DevInfo = new List<DEVICEINFO>();
......
private void BTN_ADD_Click(object sender, EventArgs e) //Add
{
DEVICEINFO temp = new DEVICEINFO();
temp.hDevice = hDevice;
hDevice = 0;
temp.nDeviceID = nDeviceID;
temp.strModel = strModel;
temp.strIpAddress = strIpAddress;
temp.nPort = nPort;
temp.strId = strID;
temp.strPasswd = strPW;
DevInfo.Add(temp);
......
}
private void BTN_REMOVE_Click(object sender, EventArgs e) //Delete
{
int nDeviceID = int.Parse(LISTVIEW_DEVICE.Items[nSelItem].SubItems[0].Text);
DEVICEINFO result = DevInfo.Find(
delegate(DEVICEINFO temp)