Mike
Thu Nov 29 17:15:00 PST 2007
Ok, I follow that somewhat. The syntax is simply interpreted as a series of
function calls, etc.
Thanks,
Mike
"Jon Skeet [C# MVP]" wrote:
> Mike <Mike@discussions.microsoft.com> wrote:
> > Correct me if I'm wrong please, but doesnt LINQ make heavy use of the types
> > defined in System.Linq - such as IQueryable<>, IGrouping<>, etc?
>
> LINQ itself does - but strictly speaking, LINQ isn't a language
> feature. The word LINQ only appears in the C# 3 spec in namespaces.
>
> The C# 3 feature *enabling* LINQ is query expressions, and they can
> work with anything that provides the appropriate methods. For instance:
>
> public delegate TRet FakeFunc<TIn, TRet>(TIn x);
>
> public class FakeLinq
> {
> public FakeLinq Where(FakeFunc<FakeLinq,bool> x)
> {
> return null;
> }
>
> public T Select<T>(FakeFunc<FakeLinq,T> y)
> {
> return default(T);
> }
> }
>
> class Test
> {
> static void Main()
> {
> var x = from z in new FakeLinq()
> where z==null
> select z.ToString();
> }
> }
>
> Not an IEnumerable<T> in sight. The above would compile with the C# 3
> compiler targeting .NET 2.0, and run under .NET 2.0.
>
> >
> >
> > "Jon Skeet [C# MVP]" wrote:
> >
> > > Mike <Mike@discussions.microsoft.com> wrote:
> > > > I believe they are tied to both the language and the runtime (only the 3.5
> > > > version of csc.exe/vbc.exe can compile them), and the framework was extended
> > > > to support them. Just try compiling with 2.0/3.0 as target or under VS2005 -
> > > > as you can see, both are required.
> > >
> > > You can use almost all of the C# 3 features when using 2.0 or 3.0 as
> > > the target, and when doing so they'll run perfectly well without the
> > > 3.5 runtime. Indeed, with appropriate support of 3rd party libraries,
> > > query expressions will work just fine.
> > >
> > > The only language feature which absolutely definitely requires 3.5 is
> > > expression trees. Lambda expression to delegate conversion is fine,
> > > anonymous types are fine, extension methods are fine with the addition
> > > of a single extra attribute...
> > >
> > > --
> > > Jon Skeet - <skeet@pobox.com>
> > >
http://www.pobox.com/~skeet Blog:
http://www.msmvps.com/jon.skeet
> > > World class .NET training in the UK:
http://iterativetraining.co.uk
> > >
> >
>
> --
> Jon Skeet - <skeet@pobox.com>
>
http://www.pobox.com/~skeet Blog:
http://www.msmvps.com/jon.skeet
> World class .NET training in the UK:
http://iterativetraining.co.uk
>