ispiro
ispiro

Reputation: 27723

If Visual Studio’s Intellisense doesn’t suggest an option – does that mean it is not always supported?

I have an ObservableCollection which I’m changing to an array using string[] s = myObservableCollection.ToArray();This works fine. I noticed, however, that VS does not offer that in its auto-complete. It only offers ToArray<> . So I wonder – does this mean it’s not supported in all cases or platforms etc. ?

Upvotes: 2

Views: 321

Answers (2)

Oded
Oded

Reputation: 499352

If it compiles, it is supported.

Intellisense is not perfect and relying on it too much is a mistake. As you have seen, a perfectly valid option didn't come up.

In this case, the method is probably the IEnumerable<T>.ToArray() extension method provided by LINQ.

Upvotes: 7

Hans Passant
Hans Passant

Reputation: 942308

Right, ObservableCollection<> doesn't have a ToArray() method. You get the Linq extension method offered by IntelliSense, you no doubt have a using System.Linq directive at the top of the source code file. Which does require that the machine you install this on has at least .NET version 3.5. That's not hard to come by.

Upvotes: 1

Related Questions