Monday, 5 January 2015

C# Basics

      Introduction

              C# is a simple, modern, general-purpose, object-oriented programming language developed by Microsoft within its .NET initiative led by Anders Hejlsberg.
              C# programming is very much based on C and C++ programming languages, so if you have basic understanding on C or C++ programming then it will be a fun to learn C# programming language.

Strong Programming Features of C#

  • Boolean Conditions
  • Automatic Garbage Collection
  • Standard Library
  • Assembly Versioning
  • Properties and Events
  • Delegates and Events Management
  • Easy-to-use Generics
  • Indexers
  • Conditional Compilation
  • Simple Multithreading
  • LINQ and Lambda Expressions
  • Integration with Windows
later we will discuss about these features.

A Simple C# Program

// Namespace Declaration
using System;

// Program start class
class WelcomeCSS
  // Main begins program execution.
  static void Main()
{ // Write to output
 Console.WriteLine("Welcome to the C# Station Tutorial!");
}

}

Variables and Data types

          Variables and data types are basic requirements of any programming language. C# is a strongly typed language, it means each object and variable must be declared with a type.There are various types of data types in C# that can be used to define variable.

A data type is categorized with value type and reference type


A complete detail of C# data types are mentioned below:

Value Types:


Data TypesSizeValuesDefault value
sbyte8 bit-128 to 1270
byte8 bit0 to 2550
short16 bit-32,768 to 32,7670
ushort16 bit0 to 65,5350
int32 bit-2,147,483,648 to 2,147,483,6470
uint32 bit0 to 4,294,967,2950
long64 bit-9,223,372,036,854,775,808 to 9,223,372,036,854,775,8070L
ulong64 bit0 to 18,446,744,073,709,551,6150
char16 bit0 to 65535'\0'
float32 bit-1.5 x 1045 to 3.4 x 10380.0F
double64 bit-5 x 10324 to 1.7 x 103080.0D
decimal128 bit-1028 to 7.9 x 10280.0M
bool---True or falsefalse

Reference Types:


Data TypesSizeValuesDefault value
stringVariable length0-2 billion Unicode charactersnull
object------null












No comments:

Post a Comment