Var vs. Dynamic C# with code example

Var vs. Dynamic C# with code example

Var vs. Dynamic

C# offers variety with flavors to accomplish the task to the developers. var keyword defines a static nature which gets resolve at compile-time introduced in C# 3.0 where dynamic gets resolved at runtime introduced in C# 4.0.

Var is a statically type variable, which means values of these variables gets decoded at compile time, must be initialize at design time else compiler will throw error. Where dynamic is also statically type variables but decode happens at runtime.

Var example

Dynamic example

Next >> Multi-threading in c# with step by step example

Leave a Reply

Your email address will not be published.