我在C#中有一个IList<Node>
,Node
是一个对象,有Name
作为属性.
我需要定期在这IList<Node>
内执行搜索,具体操作如下:
List_of_Nodes.Where(o => o.Name == "Something").FirstOrDefault();
I would like to know if there is a way to speed that up.
In a database, a search within a table can be executed faster by creating an index on the column you want to search on.
Is that also possible in a C# IList
?
(I've been looking on the site, but I always get results like List_of_Nodes[index]
. It would be great it I could replace the search by List_of_Nodes[name]
, but how can I achieve that?