Should I be using int or Int16 for the paramaters for my assemblymethods?

  • Thread starter Thread starter Bruce
  • Start date Start date
B

Bruce

I have a public method in a managed class similar to void foo(int i);

I noticed something a bit curious when I complied the help file with
Sandcastle. Sandcastle is seeing the int parameters as Int32.

Should I not be using int but use Int16 so that the parameter is
compatible across all of the languages?

Bruce
 
Bruce said:
I have a public method in a managed class similar to void foo(int i);

I noticed something a bit curious when I complied the help file with
Sandcastle. Sandcastle is seeing the int parameters as Int32.

Should I not be using int but use Int16 so that the parameter is
compatible across all of the languages?

int is Int32 in .NET, and long is Int64. short is Int16.

You may be confusing int with VB6's Integer, which was 16 bits.
 
Ben Voigt said:
int is Int32 in .NET, and long is Int64. short is Int16.

Arggh! That's for C# and VB.NET. In C++/CLI, long is still a synonym for
int, and __int64 is the keyword corresponding to System::Int64 (and there is
also __int128).
You may be confusing int with VB6's Integer, which was 16 bits.
 
Ben said:
Arggh! That's for C# and VB.NET. In C++/CLI, long is still a synonym for
int, and __int64 is the keyword corresponding to System::Int64 (and there is
also __int128).

I would like to add that there's a new 64-bit integer type called long
long, which was introduced to replace the non-standard and awkward
__int64 type. I personally prefer long long or System::Int64 to __int64.
long long is part of C99 and will be part of ISO C++0x.

Tom
 
Back
Top