A data type defines how much storage a piece of data will take up, the configuration of that storage, and the meaning of the data. Predefined or primitive data types are those defined by the language. These primitive data types can be used as building blocks for user-defined data types.
Welcome to Bucaro TecHelp!

Bucaro TecHelp
Maintain Your Computer and Use it More Effectively
to Design a Web Site and Make Money on the Web

About Bucaro TecHelp About BTH User Agreement User Agreement Privacy Policy Privacy Site Map Site Map Contact Bucaro TecHelp Contact RSS News Feeds News Feeds

Victims of Sandy Hook

Stop the Slaughter of Innocents. Congress is bought and paid for by gun lunatics and gun promotion groups. If you want to live in a safe America, help buy Congress back for America. Send a donation to Mayors Against Illegal Guns, 909 Third Avenue, 15th Floor New York, NY 10022


C# Predefined Primitive Data Types

Programs often work with data. This data must be stored in the computer's memory chips or on some non-volatile storage media, such as a hard disk. A data type defines how much storage a piece of data will take up, the configuration of that storage, and the meaning of the data. For example a text character will take up 16 bits of storage that are code for an ASCII or Unicode character. A floating-point number will take up 32 bits of storage, and will have two parts, the "mantissa," and the "exponent".

Predefined or primitive data types are those defined by the language. These primitive data types can be used as building blocks for user-defined data types. In addition, primitive data types may be arranged in a row to form a string data type, or rows and/or columns to form an array data type.

Integer Data Types

Type Range Size
sbyte -128 to 127 Signed 8-bit integer
byte 0 to 255 Unsigned 8-bit integer
char U+0000 to U+ffff Unicode 16-bit character
short -32,768 to 32,767 Signed 16-bit integer
ushort 0 to 65,535 Unsigned 16-bit integer
int -2,147,483,648 to 2,147,483,647 Signed 32-bit integer
uint 0 to 4,294,967,295 Unsigned 32-bit integer
long -9,223,372,036,854,775,808 to
9,223,372,036,854,775,807
Signed 64-bit integer
ulong 0 to 18,446,744,073,709,551,615 Unsigned 64-bit integer

Floating-Point Data Types

Type Approximate range Precision
float 1.5e-45 to 3.4e38 7 digits
double 5.0e-324 to 1.7e308 15-16 digits

Floating point numbers have two parts, the "mantissa," which holds the significant digits, and the "exponent", which indicates the location of the decimal point. Floating point notation is usually used to define very large numbers. The "precision" of a floating point number is indicated by the mantissa.

Decimal Data Type

Type Approximate range Precision
decimal 1.0 10-28 to 7.9 1028 28-29 significant digits

The decimal data type is a 128-bit data type. Compared to floating-point types, the decimal type has a greater precision (but a smaller range), which makes it suitable for financial and monetary calculations.

Shown below is C#exmple code that declares a variable a of type int and then assigns it a value of 5.

using System;

namespace HelloWorld
{
    class UseVariable 
    {
        static void Main() 
        {
            int a;
            a = 5;
            System.Console.WriteLine(a);

 	// wait until user presses Enter key
	Console.ReadLine();
        }
    }
}

If you want to compile and run this example, see Compile C# Without Visual Studio

RSS Feed RSS Feed


Follow Stephen Bucaro Follow @Stephen Bucaro


Fire HD
[Site User Agreement] [Privacy Policy] [Site map] [Search This Site] [Contact Form]
Copyright©2001-2017 Bucaro TecHelp 13771 N Fountain Hills Blvd Suite 114-248 Fountain Hills, AZ 85268