Why can't JObject call the linq method?

Newtonsoft.Json.Linq.JObject clearly implements IEnumerable < T > , specifically IEnumerable < KeyValuePair < string, JToken > , after reading the metadata and source code, it is not explicitly implemented. It is said that objects of type JObject can directly call Select, Where and other linq extension methods, but the code is as follows:

using System.Linq;
...
var jobj = new JObject();
var xxx = jobj.Select(x=>x); //:JObjectSelect1JObjectSelect...
foreach(var x in jobj) { } //

I really don"t know any reason, so I ask for advice.


asked why JObject , in addition to implementing a IEnumerable < KeyValuePair < string, JToken > > , another interface it implements JContainer also implements a IEnumerable < JToken > , which equals to JObject directly and indirectly implements two different IEnumerable < T > . When .Select , the compiler is not sure which one to call.

can be called after explicitly converting jobj to IEnumerable < XXX > .

Menu