Другое решение:
читает следующий ключ реестра:
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductName
или другие ключи от
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion
Depends on your position. ReadOnlyCollection
works very well when you have an internal modifiable list that needs to be given to some other code that isn't allowed to change the list. For simple code, using ReadOnlyCollection
is probably overkill. If the code is large and there's a risk some other programmer (or you, down the road) might accidentally attempt to modify the list, then it might be worth it.
In short: don't use ReadOnlyCollection
idiomatically, use it when it makes sense.
По возможности предпочитайте статическую проверку типа. IEnumerable
доступен только для чтения.
IEnumerable<string> list = new List<string> { "type", "currency", "date", "amount" };
Последующий код не может изменить список, и ошибки будут обнаружены во время компиляции - если вы не используете отражение, но тогда отражение можно использовать для обхода проверок во время выполнения, как хорошо.