Why can't I use ToList() with my KeyCollection

.net, c#, dictionary

Solution

This is fixed by adding a

using System.Linq;

to the top of the .cs file.

(Jon, since you led me to the right path, if you want to post this as an answer, do so, and I'll erase this answer and give you credit.)

Problem

I'm trying to modify each value in a Dictionary. The answers about how to do that generally look like this (taken from here): ``` foreach (var key in myDictionary.Keys.ToList()) { myDictionary[key] = <some kind of new value> } ``` Seemingly straightforward, but it doesn't work for me; Visual Studio underlines ToList() and says 'System.Web.UI.WebControls.QueryableDataSourceHelper.ToList(System.Linq.IQueryable, System.Type)' is inaccessible due to its protection level. Am I doing something wrong? (Obviously yes, but what?)

Original source

Related problems