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.