日期:2014-05-17  浏览次数:20809 次

委托
委托:是一种类型安全的函数指针。可是下面用到的委托好像并不代表什么函数,这是怎么回事呢?
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)