Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 519781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:04:36+00:00 2026-05-13T08:04:36+00:00

Somewhat academic question, but: How do value types like Int actually work ? I’ve

  • 0

Somewhat academic question, but: How do value types like Int actually work?

I’ve used Reflector on mscorlib to find out how System.Int32 is implemented, and it’s just a Struct that inherits from System.ValueType. I was looking for something among the lines of an Array of Bits holding the value, but I only found a field that’s declared int – which means it’s a circular reference?

I mean, I can write “int i = 14;”, but the number 14 needs to be stored somewhere somehow, but I couldn’t find the “Array of 32-Bits” or a Pointer or something.

Is this some magic that the compiler does, and are these magic types part of the specification? (Similar to how System.Attribute or System.Exception are “special” types)

Edit: If I declare my own struct, I add fields to it. Those fields are of a built-in type, for example int. So the CLR knows that I hold an int. But how does it know that an int is 32-Bits, signed? Is it simply that the Specification specifies certain base types and therefore makes them “magic”, or is there a technical mechanism? Hypothetical example: If I would want to declare an Int36, that is an Integer with 36 Bits, could I create a type that works exactly like an Int32 (apart from the 4 extra bits ofc) by specifying “Okay, set aside 36 bits”, or are the built-in primitives set in stone and I would have to somehow work around this (i.e. by using an Int64 and code that only sets the last 36 Bits)?

As said, all very academic and hypothetical, but I always wondered about that.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T08:04:36+00:00Added an answer on May 13, 2026 at 8:04 am

    Certain primitive types like integers are part of the CLI specification. For example, there are specific IL instructions like ldc.i4 for loading values of these types, and IL instructions such as add have specific knowledge of these types. (Your example of int i = 14 would get compiled to ldc.i4 14, with the 14 represented internally as part of the opcode within the compiled MSIL.)

    For more info, see Partition IIa of the CLI spec, Section 7.2, “Built-in Types.” (Can’t find a link to the particular section, sorry.) The built-in types are: bool, char, object, string, float32, float64, int[8|16|32|64], unsigned int[8|1632|64], native int (IntPtr), native unsigned int, and typedref. The spec notes that they “have corresponding value types defined in the Base Class Library” which makes me think that Int32 is actually kind of a metadata wrapper around the “real” int32, which lives down at the VES level.

    Other value types, like System.Decimal, System.Drawing.Point or any structs you define in your own code, are non-magical.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Somewhat of an academic question, but I ran into this while writing some unit
I asked a somewhat related question but I want it to make it more
I know this is somewhat of a server question, but I wanted to ask
Somewhat unclear to me are references (pointers?) to classes in VB.NET. The question I
Somewhat related to my question about integers instead of decimals; my vendor provides a
Although somewhat related to this question , I have what I think is a
This is a somewhat low-level question. In x86 assembly there are two SSE instructions:
Working on a somewhat complex page for configuring customers at work. The setup is
I understand somewhat how int a = b+abs(c) can be translated to simple assembly
I have somewhat interesting development situation. The client and deployment server are inside a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.