views:

1100

answers:

4

I do not understand what is meant by the terms "compile time" and "run time" (or "runtime").

I'm also a bit confused about what "value type" and "reference type" mean, and how they relate to the 'times mentioned above.

Would someone please explain these things?

+11  A: 

"Compile time" is when you build your code - when the compiler converts your source code into IL.

"Runtime" is when your code is executed - for ASP.NET, when a page request is made. (Personally I prefer the term "execution time" to distinguish between that and "the Common Language Runtime (CLR)" - aka the virtual machine.)

Value types and reference types are an entirely separate concept, but I have an article about them which you may find useful.

Jon Skeet
thank u jon skeet
Surya sasidhar
what i have to say is for value type memory allocated at compile time and for reference type memory allocated at runtime
Surya sasidhar
@Surya: No, that's not true at all. They're completely separate concepts - don't try to put them together.
Jon Skeet
ok ok jon skeet i understood. can u send any material for c# basic things like what is class,encapsulation,abstraction,inheritance,delegates like that i want basics of c# this is my id [email protected]
Surya sasidhar
Do not ask here to send any material to your email id. Better ask for some link.
rahul
Or buy Jon's book!
Ian Nelson
+2  A: 

A variable that is a value type, stores the data, while a variable of a reference type stores a reference to the data.

In computer science, compile time refers to either the operations performed by a compiler (the "compile-time operations"), programming language requirements that must be met by source code for it to be successfully compiled (the "compile-time requirements"), or properties of the program that can be reasoned about at compile time.

The operations performed at compile time usually include syntax analysis, various kinds of semantic analysis (e.g., type checks and instantiation of template) and code generation.

In computer science, the qualifier run time, run-time, runtime, or execution time refers to the period while a computer program is actually executed ("run") in a computer, from beginning to termination. It may also mean the program's running time, the duration of that period.

rahul
Value types aren't always stored on the stack. See http://pobox.com/~skeet/csharp/memory.html
Jon Skeet
Edited my post.
rahul
Thanks @Jon for the article.
rahul
A: 

As to your first question, see Stack Overflow: Runtime vs Compile time.

As to your second question, see Stack Overflow: What are the differences between value types and reference types in C#.

As to how they relate: they are independent concepts. Setting a variable's value and reading its value happens at run time; whether or not that variable has value type or reference type.

David Cary
A: 

Compile time is behind the scenes building. Run time is when you execute. I also call it "find the error time".