Archive

Archive for the ‘3.5 framework’ Category

Difference between Var and Dynamic keywords in .net framework

September 11, 2010 Leave a comment

Below is the brief detail for when to use var and when to use Dynamic,

Var keyword : Come in picture after release of .net framework 3.0, porvides flexibility to implicitly assign a variable to Var object, which is then finally decide by compiler.

Dynamic Keyword: Come in picture with release of .net frameword 4.0,Can be assigned dynamicallly at runtime.

Below is more difference from MSDN:


The keywords var and dynamic are only apparently similar. Var indicates that the type of the variable has to be set to the compile-time type of the initializer.

But dynamic means that the type of the variable is the dynamic type as available in C# 4.0. In the end, dynamic and var have quite opposite meanings. Var is about reinforcing and improving static typing. It aims to ensure that the type of a variable is inferred by the compiler looking at the exact type being returned by the initializer.

The keyword dynamic is about avoiding static typing altogether. When used in a variable declaration, dynamic instructs the compiler to stop working out the type of the variable at all. The type has to be intended as the type it happens to have at run time. With var, your code is as statically typed as it would have been had you opted for the classic approach of using explicit types in a variable declaration.

Another difference between the two keywords is that var can only appear within a local variable declaration. You can’t use var to define a property on a class, nor can you use it to specify the return value or a parameter of a function.

As a developer, you use the dynamic keyword with variables expected to contain objects of uncertain type such as objects returned from a COM or DOM API; obtained from a dynamic language (IronRuby, for example); from reflection; from objects built dynamically in C# 4.0 using the new expand capabilities.

The dynamic type doesn’t bypass type checks, though. It only moves them all to run time. If type incompatibilities are discovered at run time, then exceptions are thrown.

Click here for more research,

Advertisements

Why do i go with entity framework?

September 3, 2010 Leave a comment

I read up at number of places that why should i go with entity framework rather with L2S,nHiebernet or ADO.net

But i found a useful link for you all to help you out to understand the exact features which are more helpful to you than other ORM tool,

Click here for complete detail,