C Sharp/Data Types

From Meshplex

Jump to: navigation, search
Image:Csharp_programming.gif

Main Home

Basics
C# Tutorial Home
C# - Introduction to Visual Studio IDE
Introduction to C#
C# - Overview
C# - Statements
C# - Data Types
C# - Variables
C# - Operators
C# - Flow Control
C# - Variables II
C# - Functions and Methods
C# - Classes and Objects I
C# - Enumerations
C# - Dates and Times
C# - Random Numbers

Advanced
C# - Inheritance
C# - Polymorphism
C# - Garbage Collection
C# - Operator Overloading
C# - Encapsulation
C# - Properties
C# - Indexers
C# - Exceptions
C# - GUI
C# - Delegates
C# - Events
C# - Components
C# - Multithreading
C# - Regular Expressions
C# - Graphics and Multimedia
C# - Files and Streams
C# - XML
C# - Database, SQL and ADO.NET
C# - ASP.NET Web Forms and Web Controls
C# - Web Services
C# - Network Programming
C# - Datastructures and Collections
C# - Enumerations and Iterators
C# - .NET Assemblies
C# - CLR
C# - Visual Studio Debugger
C# - Namespaces
C# - Generics
C# - MS Intermediate Language
C# - Deploying Windows Application

[edit] Introduction to predefined types

Almost everything in C# invloves types. if you want to add two numbers togther you will need to specify a type for each variable. A "type" tells the computer what kind of variable it is dealing with. For example, decimals, whole numbers, strings (words), etc; in C# these types must be declared or the compiler will not know what kind of variable it's dealing with. In the C# language it can only calculate decimals with decimals, string with strings, whole numbers with whole numbers, etc. This is why types must be declared.

[edit] User defined Types

UDTs are types that are created by the programmer. They are custom types and have proved to be very useful application development. You will unlock the true power of C# when you learn how to create UDTs by using classes. UDTs will be discussed in greater detail later in this tutorial.

[edit] List of C# Data Types

Here are the C# predefined types:


Keyword Bytes .NET Type Range
byte 1 System.Int16 0 to 255
sbyte 1 System.SByte -128 to 127
char 1 System.Char Unicode
bool 1 System.Boolean 0 to 1
short 2 System.Int32 -32,768 to 32767
ushort 2 System.Uint16 0 to 65,535
int 4 System.Int32 -2,147,483,647 to 2,147,483,647
uint 4 System.UInt32 0 to 4,294,967,295
float 4 System.Single

–1.5x10-45 to 3.4x1038

double 8 System.Double

–5.0x10-324 to 1.7x10308

decimal 8 System.Decimal

1.0x10-28 to 7.9x1028

long 8 System.Int64

–9223372036854775808 to 9223372036854775807

ulong 8 System.Uint64

0 to 18446744073709551615

Personal tools