Are expression trees the main language of C #?

Are expression trees the main language or function of the BCL object / library? Is that something you cannot build without the basic features of C #?

+6
source share
2 answers

No, expression trees are not language features. They can be used from any .NET language, so they cannot be C # specific. These are common CLR types defined in the built-in assembly.

The construction using lambda expressions (and LINQ) is specific to C #. But you can always create an equivalent Expression manually. The C # compiler itself does nothing but call calls to the well-known static methods of building Expression . You can verify that the compiler emitted by decompiling the binary with Reflector configured on the old version of .NET.

Whether expression trees are internal .NET Framework APIs is not a related issue, but I can't think of any reason they need it.

+3
source

As you can see from the definition of the Expression class, it is defined in the System.Linq.Expressions namespace. This expression is not a function of the C # language; it is a class that is consumed by all CLR-oriented languages.

Here, for example, there is an article about MSDN called " Expression Trees" (C # and Visual Basic) , illustrating how to create and consume expression trees using C # and VB.NET.

0
source

Source: https://habr.com/ru/post/943753/


All Articles