So we've finally got VS2010 on some developer stations at work and can use the C# 4.0 features. Although most of what we develop will still have to target .Net 3.5 for the time being.
When I start a new project and set the target to .Net 3.5, it still allows me to use C# 4.0 such as dynamic. Can you therefore use C#4.0 features whilst targetting .net 3.5 and will these features work in environments where .Net 4.0 is not available?
Thanks.
C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...
Compared to other languages—like Java, PHP, or C#—C is a relatively simple language to learn for anyone just starting to learn computer programming because of its limited number of keywords.
What is C? C is a general-purpose programming language created by Dennis Ritchie at the Bell Laboratories in 1972. It is a very popular language, despite being old. C is strongly associated with UNIX, as it was developed to write the UNIX operating system.
History: The name C is derived from an earlier programming language called BCPL (Basic Combined Programming Language). BCPL had another language based on it called B: the first letter in BCPL.
dynamic
code will not compile if you target the .NET 3.5 framework.
To be more clear, the compiler will allow you to define and assign a dynamic
variable, such as:
dynamic x = 3;
That one line of code will compile, because dynamic
just compiles to object
as far as types are concerned. But if you then try to do anything with that variable, as in:
Console.WriteLine(x);
... then the compiler would have to generate code to discover/coerce the real type, which it cannot do; you'll get the following compile errors:
- Predefined type 'Microsoft.CSharp.RuntimeBinder.Binder' is not defined or imported
- One or more types required to compile a dynamic expression cannot be found. Are you missing references to Microsoft.CSharp.dll and System.Core.dll?
The C# 4 compiler relies on the DLR and specifically the Microsoft.CSharp assembly for everything related to dynamic
. These aren't available in .NET 3.5. So the answer is no, you cannot use dynamic
when targeting Framework version 3.5.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With