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
using System;
// Program start class
class WelcomeCSS
{
{
// Main begins program execution.
}
static void Main()
{ // Write to output
{ // 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 Types | Size | Values | Default value |
|---|---|---|---|
| sbyte | 8 bit | -128 to 127 | 0 |
| byte | 8 bit | 0 to 255 | 0 |
| short | 16 bit | -32,768 to 32,767 | 0 |
| ushort | 16 bit | 0 to 65,535 | 0 |
| int | 32 bit | -2,147,483,648 to 2,147,483,647 | 0 |
| uint | 32 bit | 0 to 4,294,967,295 | 0 |
| long | 64 bit | -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 | 0L |
| ulong | 64 bit | 0 to 18,446,744,073,709,551,615 | 0 |
| char | 16 bit | 0 to 65535 | '\0' |
| float | 32 bit | -1.5 x 1045 to 3.4 x 1038 | 0.0F |
| double | 64 bit | -5 x 10324 to 1.7 x 10308 | 0.0D |
| decimal | 128 bit | -1028 to 7.9 x 1028 | 0.0M |
| bool | --- | True or false | false |
Reference Types:
| Data Types | Size | Values | Default value |
|---|---|---|---|
| string | Variable length | 0-2 billion Unicode characters | null |
| object | --- | --- | null |
No comments:
Post a Comment