使用比较参数实例化嵌套字典的语法
我应该如何使用比较参数实例化嵌套字典? 我可以创建一个字典,但我不确定如何在嵌套时传递参数。
var single = new ConcurrentDictionary<byte[], ulong>(new ByteArrayComparer());
//Where do I put ByteArrayComparer?
var nested = new ConcurrentDictionary<ulong, ConcurrentDictionary<byte[], ulong>>();
How should I instantiate a nested dictionary with a compare parameter?
I can create a single dictionary, but I am unsure how to pas the param when nested.
var single = new ConcurrentDictionary<byte[], ulong>(new ByteArrayComparer());
//Where do I put ByteArrayComparer?
var nested = new ConcurrentDictionary<ulong, ConcurrentDictionary<byte[], ulong>>();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要在用作“外部”字典中条目的值的每个字典中指定它。不同的值完全有可能使用不同的比较器:
You'd need to specify it in each dictionary you use as a value for an entry in the "outer" dictionary. It's entirely possible for different values to use different comparers: