0% found this document useful (0 votes)
37 views

Introduction To C#

The document provides an introduction to C# programming frameworks. It discusses programming frameworks in general and the Microsoft .NET framework specifically. It describes the structure of C# programs, including namespaces, blocks, and declaration spaces. It also covers key C# concepts like data types, features, and the use of the Visual Studio integrated development environment.

Uploaded by

lion man
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views

Introduction To C#

The document provides an introduction to C# programming frameworks. It discusses programming frameworks in general and the Microsoft .NET framework specifically. It describes the structure of C# programs, including namespaces, blocks, and declaration spaces. It also covers key C# concepts like data types, features, and the use of the Visual Studio integrated development environment.

Uploaded by

lion man
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 26

University of Computer Studies

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.

 It allows us to compile all necessary resources and codes into application.

 It support multiple languages.

 It are used to save time and money.

4
Type of Programming Framework
 Web Frameworks

 Front-End Frameworks

 Back-End Frameworks

 Mobile App Development Frameworks

 Content Management Frameworks

 Data Science Frameworks

5
Microsoft .Net Framework

 The .Net framework is a software development by Microsoft.

 The .Net framework can be used to create both - Form-based and Web-based applications.

 Web services can also be developed using the .Net framework.

 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.

Common Language Runtime


 The Common Language Runtime (CLR), the virtual machine
component of Microsoft .NET framework, manages the execution
of .NET programs.
7
Cont’d
C# F# Visual
Code Code Basic
Code

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

 Window Store Application

 Mobile Application

 Web Application

 Enterprise Application

 Games
9
Integrated Development Environment (IDE)

 An IDE is a tool that helps to write program.

 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

 All statements and expressions must end with a semicolon (;)

 The program execution starts at the Main method.

 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

 Entities can be declared in namespace, class, interface, structure, enum, block.

 namespace: Declaration of classes, interfaces, structs, enums, delegates

 class, interface, struct: Declaration of fields, methods, properties, events, indexers

 enum: Declaration of enumeration constants

 block: Declaration of local variables

19
Cont’d
Scoping rules

 A name must not be declared twice in the same declaration space.

 Declarations may occur in arbitrary order.

 Exception: local variables must be declared before they are used

Visibility rules

 A name is only visible within its declaration space

 local variables are only visible after their point of declaration.

 The visibility can be restricted by modifiers (private, protected, public, etc.)

20
Namespace
It no namespace is specified anonymous default namespace

Namespaces may also contain structs, interfaces, delegates, and enums.

Namespace may be “reopened” in other files

Simplest case: single class, single file, default namespace

Equally named namespaces in different files constitute a single declaration space.

Nested namespaces constitute a declaration space on their own.

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.

 Formal parameters belong to the declaration space of the method block.

 The loop variable in a for statement belongs to the block of the for statement.

 The declaration of a local variable must precede its use.

22
Read( ), ReadLine( ), ReadKey( )

Console.Read() accepts the first character of the string and returns ASCII Code(Integer Value) of that first character.

Console.Readline() accepts the string and returns the string.

Console.ReadKey( ) obtains the next character or function key pressed by the user.

23
Syntax
 Case-sensitive

 White space means nothing

 Semicolons ( ; ) to terminate statements

 Code blocks use curly braces ( { } )

 // (for single line) or /* */ (for multi lines)

 /// (for automatic XML documentation)

24
References
 C# 5.0 Programmer’s Reference
 www.w3schools.com
 www.tutuorialTeacher.com
 www.javapoint.com
 www.tutorialspoint.com

25
Thank You

26

You might also like