Introduction To C#
Introduction To C#
Introduction to C#
1
Contents
Programming Framework
Why use Programming Framework
Types of Programming Framework
Microsoft .Net Framework
Types of Application
Integrated Development Environment (IDE)
Overview of C#
Feature of C#
Program Structure
Declaration Space
Namespace
Block
Read( ), ReadLine( ), ReadKey( )
Syntax
2
Programming Framework
A framework is a set of tools in programming on which to build well-structured, reliable software and systems.
It is ready to use collection of classes and interfaces used for developing a particular type of application.
It can include support programs, compilers, code libraries, toolsets, and APIs to develop software and create
systems.
Open-source frameworks are always being updated and improved.
3
Why use Framework
It makes programming easy.
4
Type of Programming Framework
Web Frameworks
Front-End Frameworks
Back-End Frameworks
5
Microsoft .Net Framework
The .Net framework can be used to create both - Form-based and Web-based applications.
The first version of the .Net framework was released in the year 2002.
The framework also supports various programming languages such as Visual Basic and C#, etc.
6
Cont’d
Languages
The types of applications that can be built in the .Net framework is
classified broadly into the following categories.
WinForms
ASP.Net
ADO.Net
Class Library
The .NET Framework includes a set of standard class libraries.
A class library is a collection of methods and functions that can be
used for the core purpose.
C# F# Visual Basic
Compiler Compiler Compiler
CIL
Common The Microsoft Intermediate Language (MSIL), also known as
Intermediate
the Common Intermediate Language (CIL) is a set of
Language (CIL)
instructions that are platform independent and are generated by
the language-specific compiler from the source code.
Common
Language
Runtime (CLR) CLR
The Common Language Runtime (CLR)'s just in time (JIT)
Machine code compilation converts Intermediate Language (MSIL) to native
101000001101001 code on demand at application run time. 8
Types of Application
Console Application
Window Application
Mobile Application
Web Application
Enterprise Application
Games
9
Integrated Development Environment (IDE)
Viusal Studio is an IDE provided by Micorsoft to write the code in the language such C#, F#, VisualBasic,etc.
10
Cont’d
11
Cont’d
12
Overview of C#
C# is a simple & powerful object-oriented programming language developed by Microsoft.
C# can be used to create various types of applications, such as web, windows, console applications or other types
of applications using Visual studio.
C# was developed by Anders Hejlsberg and his team during the development of .NET Framework.
The ‘#’ comes from the musical notation meaning C# is higher than C.
The safety of Java
The ease of Visual Basic
The power of C++
It uses the .NET Framework
13
Cont’d
C# compiler translates C# code into assembly-like language called Intermediate Language (IL).
CLR (Common Language Runtime) is a virtual machine component of the .Net Framework that translates IL into native
machine code when run a C# program.
CLR use a just-in-time complier (JIT compiler) to compile pieces of IL code.
14
Features of C#
C# is case sensitive
Unlike java, program file name could be different from the class name.
15
Program Structure
using System;
using System.Data;
namespace <project name>
{
<modifier > class <class name>
{
static void Main()
{
[statements]
}
}
}
16
Cont’d
C# program consist of the following parts:
using System;
Namespace declaration
namespace MyFirstProgram
A class
{ class Testing
Class methods
{
Class attributes
static void Main(string[] args)
A Main method
{
Statements and Expressions
/* my first program in C# */
Comments
Console.WriteLine(“Good Morning, Welcome To C# Class");
Console.ReadLine();
}
}
}
17
Cont’d
using System;
namespace MyFirstProgram
{ class Rectangle
{
public double width;
public double height;
public void CalculateArea( )
{
double area = width * height;
Console.WriteLine( “ Area of Rectangle :”+ area);
}
}
18
}
Declaration Space
The program area to which a declaration belongs
19
Cont’d
Scoping rules
Visibility rules
20
Namespace
It no namespace is specified anonymous default namespace
21
Block
In C#, a code block is a group of lines of code between curly braces {} .
The declaration space of a block includes the declaration spaces of nested blocks.
The loop variable in a for statement belongs to the block of the for statement.
22
Read( ), ReadLine( ), ReadKey( )
Console.Read() accepts the first character of the string and returns ASCII Code(Integer Value) of that first character.
Console.ReadKey( ) obtains the next character or function key pressed by the user.
23
Syntax
Case-sensitive
24
References
C# 5.0 Programmer’s Reference
www.w3schools.com
www.tutuorialTeacher.com
www.javapoint.com
www.tutorialspoint.com
25
Thank You
26