Crirus,
In addition to Fergus & Herfried's comments, remember a constant doesn't
really occupy any space as a variable would, the value itself is used in the
IL instructions when ever it is referenced.
To expand on Fergus's comments:
Public Const myByte As Byte = 1
Public Const myInteger As Integer = 1
Produce the same IL code when used, the 'size' (Byte verses Integer) is used
by the compiler to allow or disallow values on the constant itself.
Interesting enough both of the above can be assigned to a Byte variable!
Dim i As Byte = myByte
IL_0001: ldc.i4.1
IL_0002: stloc.2
Dim j As Integer = myInteger
IL_0003: ldc.i4.2
IL_0004: stloc.3
The "ldc" instruction is load constant, the ".i4" says Int32, the ".1" says
load the value 1. The "stloc" is the store location instruction, the ".2" &
".3" are location 2 & location 3 which is the third & fourth variable in
this routine (variable locations start with zero).
Public Const myConst = 1
This causes a compile error if you are using Option Strict On.
Hope this helps
Jay
"Crirus" <Cr****@datagroup.ro> wrote in message
news:Ok****************@TK2MSFTNGP11.phx.gbl... If I declare a constant like
Public Const myConst as Byte =1
or I declare
Public Const myConst = 1
there is any difference?
--
Ceers,
Crirus
------------------------------
If work were a good thing, the boss would take it all from you
------------------------------