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?
5
  • 1
  • Calling System.Runtime.InteropServices.Marshal.SizeOf on a variable of type System.Int32 results in...? You didn't finish that sentence.
    – diadem
    Jul 7, 2010 at 18:07
  • @diadem: He did, but someone misunderstood and edited the question. Jul 7, 2010 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 7, 2010 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. Jul 7, 2010 at 18:25

1 Answer 1

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.