高分求教问题:用C# 写的SOCKET SERVER 问题 当第一个客户端连接到服务器时。向服务器端发送一个包,服务发接收到数据后,发送回到每个客户端。当第二个客户端连接到服务器时。同样向服务器端发送一个包,服务发接收到数据后,发送回到每个客户端。我目前是当第二个客户端连接并向服务器发送数据后,第一个的数据就被覆盖掉了。现在我的问题是,我怎么把第一个客户端发送的数据保存住,当第二个客户端连接后,可以把第一个和第二个的包也发送到每个客户端请给出代码,不盛感激!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用hashtable不就得了using System;using System.Collections;public class SamplesHashtable { public static void Main() { // Creates and initializes a new Hashtable. Hashtable myHT = new Hashtable(); myHT.Add("First", "Hello"); myHT.Add("Second", "World"); myHT.Add("Third", "!"); // Displays the properties and values of the Hashtable. Console.WriteLine( "myHT" ); Console.WriteLine( " Count: {0}", myHT.Count ); Console.WriteLine( " Keys and Values:" ); PrintKeysAndValues( myHT ); } public static void PrintKeysAndValues( Hashtable myList ) { IDictionaryEnumerator myEnumerator = myList.GetEnumerator(); Console.WriteLine( "\t-KEY-\t-VALUE-" ); while ( myEnumerator.MoveNext() ) Console.WriteLine("\t{0}:\t{1}", myEnumerator.Key, myEnumerator.Value); Console.WriteLine(); }}/* This code produces the following output.myHT Count: 3 Keys and Values: -KEY- -VALUE- Third: ! Second: World First: Hello*/ 小问题,求高手指点! Lock(this)与Lock(Typeof(class))区别 DataGridView中添加comboBox 如何检查某个变量是否存在? TaskVision调用WebService的GetUserInfo出错 子窗体出现重复生成问题 ◆◇◆ 关于使用 C# 进行 Active Directory 编程所引发的“该服务器不愿意处理该请求”异常 ◆◇◆ WinForm里的树形菜单 c#调用delphi dll 关于DataGrid的问题,高手请进。急!!!!!!! asp.net的数据绑定的问题 如何用javascript判断本地文件大小???
using System.Collections;
public class SamplesHashtable { public static void Main() { // Creates and initializes a new Hashtable.
Hashtable myHT = new Hashtable();
myHT.Add("First", "Hello");
myHT.Add("Second", "World");
myHT.Add("Third", "!"); // Displays the properties and values of the Hashtable.
Console.WriteLine( "myHT" );
Console.WriteLine( " Count: {0}", myHT.Count );
Console.WriteLine( " Keys and Values:" );
PrintKeysAndValues( myHT );
}
public static void PrintKeysAndValues( Hashtable myList ) {
IDictionaryEnumerator myEnumerator = myList.GetEnumerator();
Console.WriteLine( "\t-KEY-\t-VALUE-" );
while ( myEnumerator.MoveNext() )
Console.WriteLine("\t{0}:\t{1}", myEnumerator.Key, myEnumerator.Value);
Console.WriteLine();
}
}
/*
This code produces the following output.myHT
Count: 3
Keys and Values:
-KEY- -VALUE-
Third: !
Second: World
First: Hello
*/