2. CONETNTS
• The language
• Syntax
• Program Structure
• Variable and data types
• Assignment and initialization
• Examples of declaration
• Distinguishing features
• Advantage over C++ and Java
3. The Language
• The C# language is intended to be a simple, modern,
general-purpose, object-oriented programming language.
• C#'s principal designer and lead architect at Microsoft
is Anders Hejlsberg
• Version and Platform:
In August 2012
C# 5.0 , .NET Framework 4.5, Visual Studio 2012
4. C# Syntax
• C# has the following syntax:
• ; are used to denote the end of a statement.
• { } are used to group statements like methods
(functions), methods into classes, and classes
into namespaces.
• Variables are assigned using an =, but compared
using ==.
• [ ] are used with arrays, both to declare them and
to get a value at a given index in one of them.
5. C# - Program Structure
A C# program basically consists of the following
parts:
• Namespace declaration
• A class
• Class methods
• Class attributes
• A Main method
• Statements & Expressions
• Comments
6. Variables & Data Types in C#
Byte String
Short Object
Int Bool
Long Decimal
Float Char
Double
• <data_type> <variable_list>;
• variable_name = value;
7. Examples of Declarations
Int myNumber = 20;
String myName = “Sygnet”;
String[ ] name = new string[20];
Int[ ,] score = new int [5,3] ;
Initializing variable
with 20
Initializing
array of string type
Initializing
array with (5 x 3)
9. Distinguishing features
• C# supports strongly typed implicit variable
keyword var.
• C# is platform dependent.
• C# has strongly typed and verbose function
pointer support via the keyword delegate
• A C# namespace provides the same level of
code isolation
• C# supports a strict Boolean data type, bool.
• Garbage collection addresses the problem
of memory leaks.
13. Advantages over C++ and java
• Formalized concept of get-set methods, so the
code becomes more legible
• More clean events management (using
delegates)