none
refrence data types maximum range for each variable RRS feed

  • Question

  • Hi to all first of all i am sorry because my first language is not english.

    I want to know maximumrange of any refrence types in c#

    forexample I know the byte data types maximum range is 255 but I don't know exactly maximum range of refrence types like array,delegate,interface,string,object


    If I understood correctly any refrence types range is 2GigByte on 32bit and 64bit platform

    thanks a lot




    • Edited by Reza1992 Friday, February 7, 2020 2:28 PM
    Friday, February 7, 2020 2:27 PM

All replies

  • See Microsoft docs.

    Then in some cases like int we can stored 2 gigabytes in an array, see also.

    https://docs.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/runtime/gcallowverylargeobjects-element

    For instance starting with numerics then look at the tree on the right for more.


    Please remember to mark the replies as answers if they help and unmarked 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.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange



    Friday, February 7, 2020 2:38 PM
    Moderator
  • I reading link that you have posted and i am searched again but   I finally didn't understand that reference types exactly rang is 2GigByte or not?
    • Edited by Reza1992 Friday, February 7, 2020 4:51 PM
    Friday, February 7, 2020 4:47 PM
  • I reading link that you have posted and i am searched again but   I finally didn't understand that reference types exactly rang is 2GigByte or not?
    Did you read about gcAllowVeryLargeObjects in my first reply? In short 64 bit by default limit is lesser than 32 bit

    Please remember to mark the replies as answers if they help and unmarked 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.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Friday, February 7, 2020 4:57 PM
    Moderator
  • I got a formula about range arrays

    Total size of array is smaller than 2GB(Exactly is 2031.99603 MB) in 32bit platform

    so any types of arrays must be less orequal 2031.99603 MB

    after this  you must calculation it in Byte =>2031.99603 *1024*1024=2130702269.15328 Byte
    2130702269.15328 Byte is total size you array can hold for any value types in 32bit platform


    The formula is this==> Total size In Byte Divided by Array Data Types Size.

    Example, for calculate maximum range of below code

    int [] a=new int[what is maximum range?];

    int32  take up 4 Byte for each variable

    so by above formula 2130702269.15328/4 ==>532675567.28832(We don't consider decimals)

    so we have 532675567==maximum range in int32 on 32bitplatform

    that's mean ==>int [] a=new int[532675567];

    another example, char [] a=new char[what is maximum range?];

    char  take up 2 Byte for each variable

    so 2130702269.15328/2==>1065351134.57664(We don't consider decimals)

    that's mean ==>char [] a=new char[1065351134];


    attention u must have  2031.99603MB free ram.

    i tested above code and I got it alonely.please publish this post for using other programmer

    thanks a lot













    • Edited by Reza1992 Saturday, February 8, 2020 7:50 PM
    Saturday, February 8, 2020 7:14 PM
  • Hi Reza1992,

    If you want let more people know your solution, you could edit your initial problem and mark the reply you posted as answer.

    Best Regards,

    Jack


    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.

    Monday, February 10, 2020 8:36 AM
    Moderator