-1

Could you some one explain me detailed difference between static type and dynamic variables in C#?

static i mean is (static type) general variable. And also how dymanic variable is different from var and object?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Veeru
  • 443
  • 2
  • 4
  • 16
  • You mean with and without the `dynamic` keyword, or the difference between the `static` and `dynamic` keywords? – BoltClock Jan 10 '11 at 08:06
  • @chibacity: Oh, think of all the possibilities we could come up with. – BoltClock Jan 10 '11 at 08:08
  • Can anyone tell me the common ground between them? – Cheng Chen Jan 10 '11 at 08:08
  • Seems he about 'var' keyword.. Right? – Andrew Orsich Jan 10 '11 at 08:09
  • Do you mean instance variables? – leppie Jan 10 '11 at 08:09
  • 2
    I'd tell you "static variables are shared amongst all instances of a class and dynamic variables are late-bound" but somehow I doubt that's the answer you're looking for. – Gabe Jan 10 '11 at 08:12
  • Probably means this http://stackoverflow.com/questions/961581/whats-the-difference-between-dynamicc-4-and-var – orandov Jan 10 '11 at 08:13
  • 3
    @Veeru Please see the comments (and links) and edit the question with more details. I believe there is a valid question here, but it needs to be written more clearly. –  Jan 10 '11 at 08:16
  • static i mean is (static type) general variable. And also how dymanic variable is different from var and object? – Veeru Jan 10 '11 at 09:52
  • @Veeru You original question was not very clear at all. Unfortunately you asked the question and then left it for 1 hour before handling any comments. In that time your question was closed. It will now take 5 votes to re-open it, which is very unlikely. The question is still unclear. Perhaps you should ask a series of smaller more well-defined questions? – Tim Lloyd Jan 10 '11 at 10:03

4 Answers4

3

In this video talk, Anders Hejlsberg, does a great job in explaining what the dynamic variables are in the new C# 4.0.

http://channel9.msdn.com/Blogs/matthijs/C-40-and-beyond-by-Anders-Hejlsberg alt text

Community
  • 1
  • 1
glowworms
  • 410
  • 4
  • 8
2

Dynamic variables are seen as type Object in your source code and any members that you access from them are bound at run time. Static variables have their types known at compile-time, and hence member accesses are directly placed into the assembly at compile-time.

user541686
  • 205,094
  • 128
  • 528
  • 886
1

A dynamic variable is a variable whose address is determined when the program is run.A static variable has memory reserved for it at compilation time.

In terms of ASP.Net the Static variable is equalent to the Application variable.

KBBWrite
  • 4,373
  • 2
  • 20
  • 22
0

The type of a dynamic variable is resolved at run-time.

Xaqron
  • 29,931
  • 42
  • 140
  • 205