【发布时间】:2017-01-23 08:04:44
【问题描述】:
如何将并发字典值转换为列表,下面是我尝试的代码。
//this collection will maitain server connections/ server can support multiple connections
public static readonly IDictionary<string, ISet<ConnectionManager>> SereverConnections = new ConcurrentDictionary<string, ISet<ConnectionManager>>();
//Get All Server Connections List
public static IList<ConnectionManager> GetAllServerConnections()
{
IList<ConnectionManager> connectionList = new List<ConnectionManager>(Global.SereverConnections.Values);
return connectionList;
//return Global.SereverConnections.Values.ToList();
//return (Gloconnections.ToList() ?? Enumerable.Empty<ConnectionManager>().ToList());
}
编译时错误:
cannot convert from 'System.Collections.Generic.ICollection<System.Collections.Generic.ISet<ChatServer.ConnectionManager>>' to 'int'
【问题讨论】:
-
我想知道我的问题被否决的原因?有什么理由让我提高自我吗?
-
不知道为什么你被否决了……据我所知,这不是一个不合理的问题……显然有人认为值得回答。请务必标记最适合您的答案。给某人功劳。
标签: c# list concurrentdictionary