C# Language Dynamic type

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Remarks

The dynamic keyword declares a variable whose type is not known at compile time. A dynamic variable can contain any value, and the type of the value can change during runtime.

As noted in the book "Metaprogramming in .NET", C# does not have a backing type for the dynamic keyword:

The functionality enabled by the dynamic keyword is a clever set of compiler actions that emit and use CallSite objects in the site container of the local execution scope. The compiler manages what programmers perceive as dynamic object references through those CallSite instances. The parameters, return types, fields, and properties that get dynamic treatment at compile time may be marked with some metadata to indicate that they were generated for dynamic use, but the underlying data type for them will always be System.Object.



Got any C# Language Question?