We help IT Professionals succeed at work.

is 'design time' same as 'compile time' in C#?

IzzyTwinkly asked

I am reading a C# book.  it refers 'desgin time', like 'A class in design time is just data type, so it doesn't have any memory assigend yet.'
is 'design time' same as 'compile time'?  

Watch Question

Guy Hengel [angelIII / a3]Billing Engineer
Most Valuable Expert 2014
Top Expert 2009
in regards to that definition: yes. at compile time, the c# code is compiled into machine code (.exe/.dll), and the memory used to compile is only for the class definition, not an object's memory.

only if later the code actually runs at this line:

MyClass c = new MyClass();

Open in new window

then the object c get's initiated with the memory need to hold all of the data structures for MyClass.
Generally any program won't occupy the memeory until it's getting execute / called

If you decalre an variable in C# as

int a;

doesn't allocate memory until the call to first assignment raise

Once the execution fo code by CLR reaches the code fro assignment then the CLR will identify the Datatype and get the size of the type to allocate the memory for the varaible.


thanks for your replies.
so in C# 'design time' and 'compile time' are equivalent?
Memory allocation will happen only at runtime.
Design time has nothing to do with compiling. The real distinction relating to design time is runtime. Those are the two distinctions you'll come across, especially when designing controls.

Look up "design time versus runtime". The very first topic from MS talks about WPF controls at design time.

When in Visual Studio, your code can execute and therefore will be instantiated. It will consume memory. It's real, living code!

The issue that frequently comes up, which is why the term even exists, is that your code often needs to know if you're in design mode (Visual Studio, dragging things around, resizing forms, etc.). Your code can check this and behave accordingly.  .net is a JIT environment. When you are working with custom controls, they are compiled and running right there, long before you hit F5 to start debugging!