By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,538 Members | 875 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,538 IT Pros & Developers. It's quick & easy.

VB.NET Integer data types

P: n/a
Is the Integer data type deprecated? I am not sure what Integer data type to
use in some of my classes.

According to the URL below, if I am reading it correctly, it seems as though
I should be using the Short, Integer, and Long data types. Is this correct?
Or should I instead be using the Int16, 32, and 64 data types in my code?
Whats the best practice here?

http://www.ondotnet.com/pub/a/dotnet...b7.html?page=2
Jul 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
This has been debated a few times on the NGs.
In general, the consensus is to use the Short, Integer, and Long keywords.
They of course translate directly to the Int16, 32, and 64 data types.
The debate has mostly been "will the underlying type vary in the future?"
At some point, it probably will, just has it has changed now.
But that time isn't in the foreseeable future. Maybe when the standard
processor architecture is 128bit or something.

However, in the cases where you know you need a specific size, which is
usually limited to external API calls and I/O, then I prefer to explicitly
declare the size. For me, when I see a declaration of Int32, that tells me
that I know I need exactly 32 bits for some reason. While it is no different
than "Integer", it is more "explicit" and serves as a flag to me when
reading my code later on that it might not be safe to alter the size.

As far as platform dependence, .NET has given us the IntPtr (Integer
Pointer) type. This is the one you should pay attention to. The underlying
type can vary based on whether you are on a 32 or 64 bit platform. Clearly
it should be used for pointers.

Gerald

"Shawn Berg" <sh***@saeweb.com> wrote in message
news:eY*************@TK2MSFTNGP12.phx.gbl...
Is the Integer data type deprecated? I am not sure what Integer data type to use in some of my classes.

According to the URL below, if I am reading it correctly, it seems as though I should be using the Short, Integer, and Long data types. Is this correct? Or should I instead be using the Int16, 32, and 64 data types in my code?
Whats the best practice here?

http://www.ondotnet.com/pub/a/dotnet...b7.html?page=2

Jul 21 '05 #2

P: n/a
Even though I use C++ .NET, I am faced a similar situation. I find it easiest
to use the language-specific names(short, int, long) when decaring variables,
but if is need to use it in an array decaration I use the .NET-specific
names(Int16, Int32, Int64). That way it takes less time to type, since there
really is no difference between the 2. I hope this helps.
Jul 21 '05 #3

P: n/a
Shawn,

The integer should give you the most properiate processor format. (with the
most performance). For the windows 32 bits operating systems is that 32
bits.

As Gerald tells are there a lot of discussions in the newsgroups if the
integer should stay 32 bits.

In my opinion would mean that the developer of that language will be the
looser in time in my opinion.

Any format (larger or smaller) that does not fit the register format needs
more cycles to proccess.

I hope that this helps,

Cor
Jul 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.