CSharp.Net-Informations.com
   Home      .Net Framework      VB.NET      C#                                                                      About


  C# DataTypes

Data Types in a programming language describes that what type of data a variable can hold . CSharp is a strongly typed language, therefore every variable and object must have a declared type. The CSharp type system contains three Type categories. They are Value Types , Reference Types and Pointer Types . In CSharp it is possible to convert a value of one type into a value of another type . The operation of Converting a Value Type to a Reference Type is called Boxing and the reverse operation is called Unboxing .

When we declare a variable, we have to tell the compiler about what type of the data the variable can hold or which data type the variable belongs to.

  Syntax : DataType VariableName
  DataType : The type of data that the variable can hold

VariableName : the variable we declare for hold the values.

Example:

  int count;
  int : is the data type

count : is the variable name

The above example shows , declare a variable 'count' for holding an integer values.

The following are the commonly using datatypes in C# .

bool

The bool keyword is an alias of System.Boolean. It is used to declare variables to store the Boolean values, true and false. In C# , there is no conversion between the bool type and other types.

  C#  Runtime type : System.Boolean
  CSharp declaration : bool flag;
  CSharp Initialization : flag = true;

CSharp default initialization value : false

int

int variables are stored signed 32 bit integer values in the range of -2,147,483,648 to +2,147,483,647

  C#  Runtime type : System.Int32
  CSharp declaration : int count;
  CSharp Initialization : count = 100;

CSharp default initialization value : 0

decimal

The decimal keyword denotes a 128-bit data type.The approximate range and precision for the decimal type are -1.0 X 10-28 to 7.9 X 1028

  C#  Runtime type : System.Decimal
  CSharp declaration : decimal val;
  CSharp Initialization : val = 0.12;

CSharp default initialization value : 0.0M

string

The string type represents a string of Unicode characters. string variables are stored any number of alphabetic,

numerical, and special characters .

  C#  Runtime type : System.String
  CSharp declaration : string str;

CSharp Initialization : str = "csharp string";

        
        
C# Tutorial




CSharp Language Basics Related Contents
*     C# Types
*     C# boxing and unboxing
*     C# type conversions
*     C# Access Modifiers , CSharp Access Specifiers


   Home      VB.NET      C#
CSharp Related Topics
*     An overview of Microsoft CSharp
*     C# Language Tutorial
*     C# Statements Tutorial
*     C# Collection Tutorial
*     C# String Tutorial
*     C# File Operations Tutorial
*     C# Excel Tutorial
*     C# Crystal Reports Tutorial
*     CSharp Communication Tutorial
*     C# Ado.Net Tutorial and Source Code
*     C# ADO.NET data Providers Tutorial
*     C# Dataset Tutorial
*     C# DataAdapater Tutorial
*     Csharp DataView Tutorial
*     Csharp Remoting Tutorial
*     C# XML Tutorial
*     C# DataGridView Tutorial
   Home      VB.NET      C#
More Source Code :   
Mail to :  feedback@net-informations.com
  |  Home   |  VB.NET   |  C#   |  SiteMap   |  Terms of Use   |  About   |
net-informations.com (C) 2010
All Rights Reserved. All other trademarks are property of their respective owners.