Effective NameValueCollection Search

Is there a way to pull keys from NameValueCollection that refer to a specific template / naming convention without having to repeat each value in the collection?

+3
source share
3 answers

The collection of name values ​​is not intended to be particularly effective in such a search. Whatever method you use, it must go through all the subjects. You can use LINQ; sort of:

col.Keys.OfType<string>().Where(s => s.StartsWith("SomeString"))
+6
source

, linq, , . linq, , .

, , , / , .

+2

:

1) . , , - .., . , / . .

2) It makes no sense to implement a complex data structure if you do not need it. The first question you should ask yourself: do you really need efficiency: for a collection containing <50,000 elements, I really doubt that you will see a noticeable difference in memory, processor or performance looking for your keys with a fantastic data structure than direct linear search.

0
source

Source: https://habr.com/ru/post/1714652/


All Articles