/// <summary> /// 更改指定欄位之數值 /// </summary> /// <param name="_index">更改欄位</param> /// <param name="_ip_port">更改後數值</param> public void GoChange(int _index, GO_IP_PORT _ip_port) { if (GoIsUnique(_ip_port)) { _ip_port_list[_index] = _ip_port; } }
/// <summary> /// 新增IP&Port進入表 /// </summary> /// <param name="_ip_port">Class GO_IP_PORT</param> public void GoAdd(GO_IP_PORT _ip_port) { if (GoIsUnique(_ip_port)) { _ip_port_list.Add(_ip_port); } else { //TODO } }
/// <summary> /// 刪除列表中,傳入GO_IP_PORT物件 /// </summary> /// <param name="_ip_port">GO_IP_PORT物件</param> public void GoRemove(GO_IP_PORT _ip_port) { int _count = _ip_port_list.Count; int i; string[] _s = new string[_count]; for (i = 0; i < _count; i++) { if (_ip_port_list[i].ip == _ip_port.ip && _ip_port_list[i].ip == _ip_port.ip) { break; } } GoRemove(i); }
/// <summary> /// 檢查IP&Port是不是表中獨有(不重複)的 /// </summary> /// <param name="_item"></param> /// <returns>是獨有傳回true,否則false</returns> private bool GoIsUnique(GO_IP_PORT _item) { try { foreach (GO_IP_PORT item in _ip_port_list) { if (item.ip == _item.ip && item.port == _item.port) { return(false); } } } catch (Exception ex) { return(false); } return(true); }