tags:

views:

627

answers:

3

Hi, Where are the .Net data types stored?

A: 

They are 'stored' in various dll's.

Ed Swangren
How is this wrong exactly?
Ed Swangren
+7  A: 

If you mean "where in memory does the data get stored - on the stack or on the heap" it gets quite complicated, and partly depends on the language.

I've written an article about it which goes into more detail than I care to repeat here. Simplistic explanations such as the oft-repeated "value types live on the stack, reference types live on the heap" is hugely flawed, with the obvious counterexample of an int variable in a reference type - the value of that variable will always be stored on the heap, even though int is a value type.

However, you'd also be wise to read Eric Lippert's blog post about the matter - it's an implementation issue, and developers tend to get far too worried about it. The C# team could decide to change it all in a later version, and create a new object containing all local variables (instead of just captured ones).

Admittedly it's an important implementation detail - how much you put on the stack affects how deep your stack can be, etc - but we probably should spend so much time obsessing about it.

If this isn't what you intended the question to be about, please clarify it. For instance, you could mean:

  • Where does type meta-data exist at execution-time?
  • Where are the BCL types stored on disk?
  • Where does the JIT-compiled code for types exist, and is it stored?
Jon Skeet
A: 

All core CTS types like Int16, Int32, Int64, String , Byte and etc. are defined in MSCorLib.dll. This file can be found in C:\Windows\Microsoft.NET\Framework\v2.0.50727 directory.

All other special purpose types and classes are stored in their respective FCL [Framework Class Library] Assemblies. Like all types related to windows forms development are found in System.Windows.Form..dll and all types related to web/asp.net development are defined in System.Web..dll. You can find these and related assemblies in GAC of the local machine.

this. __curious_geek