none
Int32 vs Integer RRS feed

  • Question

  • Hi,

    Can someone please explain to me the difference between Int32 and Integer? In other words, how do the following two statements differ? I have seen many example in MSDN documentation where the variables are declared as Int32 and not as Integer....so please help me understand with some examples.....not finding good material on this on google.

    dim a as Int32
    dim b as Integer

    Sougata Ghosh

    Sunday, November 11, 2018 7:13 PM

Answers

  • Hello,

    Integer is an alias for Int32 internally and when using Integer the compiler generates the same code no matter if you use Int32 or Integer.

    EDIT

    Here is what happens when one uses Int32, Visual Studio indicates to simplify as per above.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites


    Sunday, November 11, 2018 7:54 PM
    Moderator
  • Integer and Int32 are the same primitive type of 32 bits to hold the numeric value. System.Int32   

    https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/data-types/integer-data-type

    It's all developer preference as to which one to use. A lot of generated code use System.Int32.


    • Edited by DA924x Sunday, November 11, 2018 7:55 PM
    • Marked as answer by sougata12 Tuesday, November 13, 2018 9:59 AM
    Sunday, November 11, 2018 7:54 PM
  • Hi

    As far as I know, Integer is just another name for Int32 (an alias perhaps). I believe they are completely interchangable.


    Regards Les, Livingston, Scotland

    • Marked as answer by sougata12 Tuesday, November 13, 2018 9:59 AM
    Sunday, November 11, 2018 7:55 PM
  • Church just let out? All 3 above answered at once.  :)

    Vb has a mix of syntax from previous versions and etc. Part of it is inadvertent unplanned compatible etc. So this difference may be one of those?

    In vb6 integer was today's 16 bit. Today we have int16, int32, int64 and integer is int32.

    • Marked as answer by sougata12 Tuesday, November 13, 2018 10:07 AM
    Sunday, November 11, 2018 8:38 PM
  • Hi,

    Inside Microsoft.NET
    Integer= Int32
    Long=Int64

    But this may not be the case in other .NET environments.

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by sougata12 Tuesday, November 13, 2018 10:06 AM
    Monday, November 12, 2018 9:37 AM

All replies

  • Hello,

    Integer is an alias for Int32 internally and when using Integer the compiler generates the same code no matter if you use Int32 or Integer.

    EDIT

    Here is what happens when one uses Int32, Visual Studio indicates to simplify as per above.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites


    Sunday, November 11, 2018 7:54 PM
    Moderator
  • Integer and Int32 are the same primitive type of 32 bits to hold the numeric value. System.Int32   

    https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/data-types/integer-data-type

    It's all developer preference as to which one to use. A lot of generated code use System.Int32.


    • Edited by DA924x Sunday, November 11, 2018 7:55 PM
    • Marked as answer by sougata12 Tuesday, November 13, 2018 9:59 AM
    Sunday, November 11, 2018 7:54 PM
  • Hi

    As far as I know, Integer is just another name for Int32 (an alias perhaps). I believe they are completely interchangable.


    Regards Les, Livingston, Scotland

    • Marked as answer by sougata12 Tuesday, November 13, 2018 9:59 AM
    Sunday, November 11, 2018 7:55 PM
  • Church just let out? All 3 above answered at once.  :)

    Vb has a mix of syntax from previous versions and etc. Part of it is inadvertent unplanned compatible etc. So this difference may be one of those?

    In vb6 integer was today's 16 bit. Today we have int16, int32, int64 and integer is int32.

    • Marked as answer by sougata12 Tuesday, November 13, 2018 10:07 AM
    Sunday, November 11, 2018 8:38 PM
  • Hi,

    Inside Microsoft.NET
    Integer= Int32
    Long=Int64

    But this may not be the case in other .NET environments.

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by sougata12 Tuesday, November 13, 2018 10:06 AM
    Monday, November 12, 2018 9:37 AM