c# - Why can't my Dictionary class see the ToArray() method?
c#, dictionary, extension-methods
Solution
The `Dictonary<TKey,TValue>` class does not actually have a `.ToArray` method. There is an extension method called `.ToArray` which can bind to `Dictionary<TKey,TValue>`. But this requires that System.Linq be one of your usings.
Have you verified that System.Linq is imported?
Example:
using System.Linq;
...
public void Example() {
var map = new Dictionary<string,string>();
..
var arr = map.ToArray();
}
Problem
I see in the API Dictionary has a ToArray() method (in the extension classes area), but when I try to use this from my Dictionary instance it can't see it??? How do I "enable" ToArray() for my Dictionary instance? Thanks