Sasha
Sasha

Reputation:

C# Dynamically typed language

With new features in .NET 3.5 (such as var, Lambda, linq, etc), and more on its way, we can conclude that C# not only statically typed language, but also Dynamically typed ?

Why or Why not?

Edit#1

As many posters below claim, .net 4.0 will add the dynamical type-ness to the language. Will this slow down the language?

With every release csharp takes something from different languages. In so far as .Net1.1, our forefathers didn't intend to even make it functional language....

Edit#2

I think many of you misunderstood the question; as I am referring to C# language overall, including the upcoming release 4.0. Thus, it is fair to say that the language is dynamically typed...

Upvotes: 7

Views: 1694

Answers (4)

brianary
brianary

Reputation: 9322

Commenters: Are you that sure that dynamic types can be so easily contained? I've got a feeling that their effects will spread.

Upvotes: 0

Andrew Hare
Andrew Hare

Reputation: 351486

C# is not dynamically typed - all types are statically inferred in the examples you mentioned. The next version of C# will include some dynamic features though for working with COM and truly dynamic languages.

[Edit #1] Yes C#'s new dynamic feature will be slower as everything using it will require late-binding. However it will only slow down your application if you use it - it is not a change to the core language itself. C# 4 will be a statically typed language with the capability of working with late-bound types.

[Edit #2] No C# 4 will not be a dynamically typed language. C# 4 introduces a new dynamic type which will substitute late-binding on type members in lieu of static type checking. Dynamic capabilities will only be available on these dynamic types. C#'s underlying type system has not changed.

Upvotes: 13

Mehrdad Afshari
Mehrdad Afshari

Reputation: 421978

Dynamically typed?! Nope. Technically, C# is a statically typed language. It has dynamic method dispatching capabilities through CLR reflection services provided by .NET runtime (which has been available since v1.0 and has nothing to do with .NET 3.5 features, C# 3.0 features are still statically typed). C# 4.0 will have true dynamic typing.

Upvotes: 1

Quintin Robinson
Quintin Robinson

Reputation: 82335

No, it is still statically typed, var/lambda/linq all use inferance by the compiler so the type is known at compile time, dynamic/duck typing will come with c# 4.0

Upvotes: 2

Related Questions