C#
  Home arrow C# arrow Page 2 - C# Simplified
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Moblin 
JMSL Numerical Library 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
C#

C# Simplified
By: Anand Narayanaswamy
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 10
    2005-03-01

    Table of Contents:
  • C# Simplified
  • Different Types of Data Types
  • Value Types and Reference Types
  • Boxing and Unboxing
  • Classes

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    C# Simplified - Different Types of Data Types


    (Page 2 of 5 )

    The .NET Framework provides lot of data types which you can use for developing applications. Since these data types are provided by the Common Language Runtime (CLR), all .NET languages such as C#, Visual Basic .NET can take advantage of them. A complete list of all data types and its range values are given in Table 1.

    Table 1  List of Data Types

    Data Type Prefix.NET DataType Min Value Max Value
    sbyteSystem.Sbyte-128127
    byteSystem.Byte0255
    shortSystem.Int16 -32,768 32,767
    ushortSystem.UInt16065,535
    intSystem.Int32 -2,147,483,648 2,147,483,647
    uintSystem.UInt32 04,294,967,295
    longSystem.Int64-9,223,372,036,854,775,8089,223372,036,854,775,808
    ulongSystem.UInt64018,446,744,073,709,551,615
    charSystem.Char065,535
    floatSystem.Single1.5 x 10^-45 3.4 x 10^38
    doubleSystem.Double5.0 x 10-3241.7 x 1010308
    boolSystem.BooleanFalse (0)True (1)
    decimalSystem.Decimal1.0 x 10-287.9 x 1028

    Operators

    With the help of operators, you can manipulate values and perform arithmetical operations. For instance, if you have to add three numbers you must use the addition (+) symbol. In the same way, if you have to multiply three numbers, you must use the * symbol. In programming parlance, these symbols are known as Operators. You will use them extensively when you develop applications such as calculator.

    C# offers a wide variety of operators which can be used for various purposes. Table 2 lists all the available operators in C# in the order of their precedence.

    Table 2 List of Operators

    Name of the OperatorDescription
    Primary Operators()  . []  x++ x--  new  typeof  sizeof  checked  unchecked
    Unary+  -  !  - ++x --x
    Multiplicative *  /  %
    Additive+   -
    Shift <<   >>
    Relational<   >   <=   >=  is
    Equality= = !=
    Bitwise AND&
    Bitwise XOR^
    Bitwise OR|
    Conditional AND && (Used for evaluating conditions using if-else)
    Conditional OR ||   (Used for evaluating conditions using if-else)
    Conditional?:  (Used for evaluating conditions instead of if-else)
    Assignment= *= /= %= += -= <<= >>=  &= ^= !=

    Let us now look at a simple C# program which illustrates the functioning of one of the operators listed in the table above.

    Listing 1.2

    001: using System;
    002:
    003: class Oper
    004: {
    005: public static void Main()
    006: {
    007:
    008: int x = 50;
    009: int y = 100;
    010:
    011: if ((x<y && y>x)) {
    012:
    013: Console.WriteLine("X is less than Y");
    014: }
    015:
    016: else {
    017:
    018: Console.WriteLine("Condition not satisfied");
    019: }
    020:
    021: }
    022: }

    In the above listing, the condition in line 11 will execute only when both the parameters are correct. If any one of the parameters is false the statements inside the else part will be printed as output.

    In the next section, you will learn about the concept of value and reference types in C#.

    More C# Articles
    More By Anand Narayanaswamy


       · This is a good beginning. It is simple enogh for a newbie. Perhaps it should be...
     

    C# ARTICLES

    - C# Exceptions
    - Methods in C#
    - Delegates and Events in C#
    - Advanced C#
    - Working with Regular Expressions in C#
    - Sending Simple E-Mail in C#
    - Building C# Comparable Objects: IComparable ...
    - Color Transformation Applications in C# GDI+...
    - Performing Color Transformation Operations i...
    - Color Transformation in C# GDI+ Programming
    - Exceptions in C#
    - Overriding versus Overloading
    - Value Types and Reference Types
    - Defining Member and Type Visibility
    - Managing Files in C#





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
    Stay green...Green IT