i have doubt i don't know what is compile time and what is开发者_高级运维 runtime in C#. i get this words from polymorphism (Method overloading, method overriding) can u explain me. Thank you
Method overloading is determined at compile time. That means that the compiler knows exactly which code will be executed when you call an overloaded method. It can produce a direct call to the code without adding any checks that would have to be done when the code runs.
Method overriding is determined at runtime. When you call a virtual method the actual method to call is determined from the actual type of the object, and this check has to be done when the call is done. As a reference can potentially reference objects of different types, the compiler can't determine from the reference type which method will be called, so it has to add code for looking up which class to get the method from.
The internal actions that are produced when the commands are obeyed by the computer, i.e. at "run time".
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.
Ref:- http://www.cs.bham.ac.uk/research/projects/poplog/primer/node35.html http://en.wikipedia.org/wiki/Compile_time
When you press F6 in VS IDE, you are compiling. The consumed time is compile-time.
When you press F5 or Ctrl+F5 in VS IDE, you are running. The consumed time is run-time.
精彩评论