3

Possible Duplicate:
C#, int or Int32? Should I care?

Couple of questions on System.Int32:

  1. Is there any specific technical reason why sizeof(System.Int32) is not allowed?
  2. How fast or slow is System.Int32 in comparison to int type?
  3. Calling System.Runtime.InteropServices.Marshal.SizeOf on a variable of type System.Int32 results in 4; how does this work? Would the size of this class be exactly same as that of int internally?
Community
  • 1
  • 1
Fanatic23
  • 3,378
  • 2
  • 28
  • 51
  • 1
    Duplicate. http://stackoverflow.com/questions/62503/c-int-or-int32-should-i-care – mcandre Jul 07 '10 at 18:05
  • Calling System.Runtime.InteropServices.Marshal.SizeOf on a variable of type System.Int32 results in...? You didn't finish that sentence. – diadem Jul 07 '10 at 18:07
  • @diadem: He did, but someone misunderstood and edited the question. – Adam Robinson Jul 07 '10 at 18:08
  • @mcandre -- this is *definitely* not a duplicate. I am trying to under stand why vanilla sizeof does not work and how despite being a class the size is still maintained as 4. – Fanatic23 Jul 07 '10 at 18:16
  • 1
    Try to avoid asking multiple questions in one posting. You have three questions here, none of which actually have anything to do with each other. The first is a question about language design, the second is a question about performance, and the third is a question about an implementation detail of the marshaller. Reopen these as three separate questions and you'll be much more likely to get all of them answered. – Eric Lippert Jul 07 '10 at 18:25

1 Answers1

4

Effectivly there is no difference.

int == Int32.

The former is implicitly 32 bits, while Int32 spells it out, similarly Int64 and Int16 (long and short respectivly) do the same.

Nate
  • 30,286
  • 23
  • 113
  • 184