C# - Value Types - Built-In Value Types

Built-in numeric types are value types.
You choose a numeric type based on the size of the values and level of precision you require.

Type: System.SByte
Bytes: 1
Range: -128 to 127
Use for: Signed byte values.

Type: System.Byte
Bytes: 1
Range: 0 to 255
Use for: Unsigned bytes.

Type: System.Int16
Bytes: 2
Range: -32768 to 32767
Use for: Interoperation and other specialized users.

Type: System.Int32
Bytes: 4
Range: -2147483648 to 2147483647
Use for: Whole numbers and counters.

Type: System.UInt32
Bytes: 4
Range: 0 to 4294967295
Use for: Positive whole numbers and counters.

Type: System.Int64
Bytes: 8
Range: -922337203854775808 to -922337203854775807
Use for: Large whole numbers.

Type: System.Single
Bytes: 4
Range: -3.402823E+38 to 3.402823E+38
Use for: Floating point numbers.

Type: System.Double
Bytes: 8
Range: -179769313486232E+308 to 179769313486232E+308
Use for: Precise or large floating point numbers.

Type: System.Decimal
Bytes: 16
Range: -79228162514264337593543950335 to 79228162514264337593543950335
Use for: Financial and scientific calculations requiring great precision.

These numeric types have aliases as they are used frequently in Visual Studio.

The following are the non-numeric data types:

Type:
System.Char
Bytes: 2
Range: N/A
Use for: Single unicode characters.


Type: System.Boolean
Bytes: 4
Range: N/A
Use for: True/False values.

Type: System.IntPtr
Bytes: platform independent
Range: N/A
Use for: Pointer to a memory address

Type: System.DateTime
Bytes: 8
Range: 1/1/0001 12:00:00AM to 12/31/9999 11:59:59 PM
Use for: Moments in time.

There are many more value types in the .NET framework, but the above are essential and cover most situations.
When data is assigned between value types, the data is stored in two different locations on the stack.

Value types function as objects which means you can call methods on them.



Popularity: 8% [?]

Welcome to Kaizenlog.com If you're new here, you may want to subscribe to my RSS feed , Twitter You can contact us by using the contact form or submitting a comment. You can also share this post with your friends by clicking on the 'ShareThis' button above. Thanks for visiting!



Print This Post Print This Post





  • Related Posts



  • Leave a Reply

    Comment moderation is enabled. Your comment may take some time to appear.