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

Ask A Question

Stats

  • Questions 293k
  • Answers 293k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Finally a solution... There were two underlying problems: The binding… May 13, 2026 at 6:24 pm
  • Editorial Team
    Editorial Team added an answer It's worth mentioning as an aside that this [ for… May 13, 2026 at 6:24 pm
  • Editorial Team
    Editorial Team added an answer I assume that Apache is configured not to accept .htacces… May 13, 2026 at 6:24 pm

Related Questions

I'm using a virtualized web server and I don't remember whether it's running Windows
I got into a mini-argument with my boss recently regarding project failure. After three
I have a list that I would like to be able to enumerate so
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

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.