splash27
splash27

Reputation: 2107

Why some methods of ObservableCollection and List might be unavailable?

I work on Windows Phone 8 app. Some methods of ObservableCollection and List are unavailable at several pages (not at all pages). Such methods as OrderBy and ElementAt. So, I can't sort my items in these collections because of it. How to find the reason of it? I have no idea.

Upvotes: 0

Views: 116

Answers (2)

Jon Skeet
Jon Skeet

Reputation: 1500835

Those aren't methods on ObservableCollection or List themselves. They're extension methods provided by the System.Linq.Enumerable class.

You probably just need an added using directive in your source code to make them available:

using System.Linq;

If that triggers another error saying that the namespace System.Linq isn't found, you'll need to add a reference to the System.Core assembly.

Upvotes: 5

dcastro
dcastro

Reputation: 68670

Because those are not List<T> methods, they're extension methods defined in the Enumerable class. To use them, add using System.Linq.

Upvotes: 1

Related Questions