扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
![]() |
1using System; 3using System.Net; 5using System.Net.Sockets; 6 7 8 9namespace SocketLibrary 10 11{ 12 13 public class Connection 14 15 { 16 17 public NetworkStream NetworkStream { 18 19 get{return _networkStream;} 20 21 set{_networkStream = value;} 22 23 } 24 25 private NetworkStream _networkStream; 26 27 public string ConnectionName { 28 29 get{return _connectionName;} 30 31 set{_connectionName = value;} 32 33 } 34 35 private string _connectionName; 36 37 public Connection(NetworkStream networkStream,string connectionName) 38 39 { 40 41 this._networkStream = networkStream; 42 43 this._connectionName = connectionName; 44 45 } 46 47 public Connection(NetworkStream networkStream):this(networkStream,string.Empty) { 48 49 } 50 51 } 52 53} 54 |
1using System; 2 3 4 5namespace SocketLibrary { 6 7 public class ConnectionCollection:System.Collections.CollectionBase { 8 9 public ConnectionCollection() { 10 11 12 13 } 14 15 public void Add(Connection value) { 16 17 List.Add(value); 18 19 } 20 21 public Connection this[int index] { 22 23 get { 24 25 return List[index] as Connection; 26 27 } 28 29 set{ 30 31 List[index] = value; 32 33 } 34 35 } 36 37 public Connection this[string connectionName] { 38 39 get { 40 41 foreach(Connection connection in List) { 42 43 if(connection.ConnectionName == connectionName) 44 45 return connection; 46 47 } 48 49 return null; 50 51 } 52 53 } 54 55 } 56 57} 58 |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。