一步一步教你使用.net进行Socket通信2

5、 新建一个继承自CollectionBase的类ConnectionCollection。用于保存Connection集合。



+展开
-C#
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//使用.net进行Socket通信
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

加支付宝好友偷能量挖...


评论(0)网络
阅读(225)喜欢(0)Asp.Net/C#/WCF