简体   繁体   English

存储GUID和DateTime对象列表的最佳方法

[英]Best way to store a List of GUID and DateTime objects

I need to store a C# list of pair values GUID and Datetime. 我需要存储配对值GUID和Datetime的C#列表。

The list will be static and I wanted to be able to quickly retrieve the existence of a GUID value so speed is essential. 该列表将是静态的,我希望能够快速检索GUID值的存在,因此速度至关重要。

What's the best alternative between list, dictionary or any other searchable collection for GUID's keys? 列表,字典或GUID键的任何其他可搜索集合之间的最佳选择是什么?

I'd just use a Dictionary<Guid, DateTime> . 我只是使用Dictionary<Guid, DateTime> I'd be surprised if there was any major performance difference between using a dictionary or list, for example. 例如,如果在使用字典或列表之间存在任何重大性能差异,我会感到惊讶。 I'd see how the dictionary performs and then try something else if you're finding it slow before trying to micro-optimize before you even know if it'll be a problem. 我会看到字典是如何执行的,然后尝试其他的东西,如果你在尝试微优化之前发现它很慢,甚至在你知道它是否会成为一个问题之前。

http://blog.bodurov.com/Performance-SortedList-SortedDictionary-Dictionary-Hashtable http://blog.bodurov.com/Performance-SortedList-SortedDictionary-Dictionary-Hashtable

Based on experience, Dictionary<TKey, TValue> is all around the fastest/easiest way. 根据经验, Dictionary<TKey, TValue>是最快/最简单的方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM