SlideShare a Scribd company logo
Lecture-1:
INTRODUCTION
Prerequisites
 This module assumes that you understand the
fundamentals of
 Programming
 Variables, statements, functions, loops, etc.
 Object-oriented programming
 Classes, inheritance, polymorphism,
members, etc.
 C++ or Java
2
3
Lecture Plan
 Introduction to thecourse
 Configure the Microsoft Visual StudioIDE
 Create a simple hello world style application
 MessageBox
Introduction to the course
1
Course Objectives
Todevelopment of Interactive
applications
Toenable student to write event
drivenprograms
Todevelopment of GUIapplications
Grading
Quizzes/Assignments = 30%
Mid-termexams = 20%
Final-termexams = 50%
Languages andTools
5
What is .NET
Framework
6
✗ Net Framework is a software development platform
developed by Microsoft for building and running
Windows applications.
✗ The . Net framework consists of developer tools,
programming languages, and libraries to build
desktop and web applications. It is also used to build
websites, web services, and games.
What is .NET Framework
7
There are various implementations of .NET.
1. NET Framework is the original implementation of .NET. It supports
running websites, services, desktop apps, and more on Windows.
2. NET is a cross-platform implementation for running websites,
services, and console apps on Windows, Linux, and macOS. .NET is
open source on GitHub. .NET was previously called .NET Core.
3. Xamarin/Mono is a .NET implementation for running apps on all the
major mobile operating systems, including iOS and Android
.NET
Framework
Architecture
8
Architecture
of .NET
Framework
9
DOT NET
Framework
Architecture
10
Architecture of .NET Framework
11
The two major components of .NET Framework are the Common Language
Runtime and the .NET Framework Class Library.
The Common Language Runtime (CLR) is the execution engine that
handles running applications. It provides services like thread management,
garbage collection, type-safety, exception handling, and more.
The Class Library provides a set of APIs and types for common
functionality. It provides types for strings, dates, numbers, etc. The Class
Library includes APIs for reading and writing files, connecting to databases,
drawing, and more.
Architecture of .NET Framework
12
✗ .NET applications are written in the C#, F#, or Visual Basic programming
language. Code is compiled into a language-agnostic Common
Intermediate Language (CIL). Compiled code is stored in assemblies—files
with a .dll or .exe file extension.
✗ When an app runs, the CLR takes the assembly and uses a just-in-time
compiler (JIT) to turn it into machine code that can execute on the specific
architecture of the computer it is running on.
.NET Components : Common Language Runtime
13
Common Language Runtime
The “Common Language Infrastructure” or CLI is a platform in
dot-Net architecture on which the dot-Net programs are executed.
The CLI has the following key features:
Exception Handling – Exceptions are errors which occur when the
application is executed.
Examples of exceptions are:
• If an application tries to open a file on the local machine, but
the file is not present.
• If the application tries to fetch some records from a database,
but the connection to the database is not valid.
.NET Components : Common Language Runtime
14
Garbage Collection – Garbage collection is the process of removing
unwanted resources when they are no longer required.
Examples of garbage collection are
• A File handle which is no longer required. If the application has
finished all operations on a file, then the file handle may no
longer be required.
• The database connection is no longer required. If the application
has finished all operations on a database, then the database
connection may no longer be required.
.NET Components : Common Language Runtime
15
A developer can develop an application in a variety of .Net programming
languages.
1. Language – The first level is the programming language itself, the most
common ones are VB.Net and C#.
2. Compiler – There is a compiler which will be separate for each programming
language. So underlying the VB.Net language, there will be a separate VB.Net
compiler. Similarly, for C#, you will have another compiler.
3. Common Language Interpreter – This is the final layer in .Net which would
be used to run a .net program developed in any programming language. So the
subsequent compiler will send the program to the CLI layer to run the .Net
application.
Architecture of .NET Framework
16
The two major components of .NET Framework are the Common Language
Runtime and the .NET Framework Class Library.
The Common Language Runtime (CLR) is the execution engine that
handles running applications. It provides services like thread management,
garbage collection, type-safety, exception handling, and more.
The Class Library provides a set of APIs and types for common
functionality. It provides types for strings, dates, numbers, etc. The Class
Library includes APIs for reading and writing files, connecting to databases,
drawing, and more.
Architecture of .NET Framework
17
✗ .NET applications are written in the C#, F#, or Visual Basic programming
language. Code is compiled into a language-agnostic Common
Intermediate Language (CIL). Compiled code is stored in assemblies—files
with a .dll or .exe file extension.
✗ When an app runs, the CLR takes the assembly and uses a just-in-time
compiler (JIT) to turn it into machine code that can execute on the specific
architecture of the computer it is running on.
Configure the IDE
18
 After you open Visual Studio, you can identify the tool windows,
the menus and toolbars, and the main window space.
Tool windows are docked on the left and right sides of the
application window, with Quick Launch, the menu bar, and the
standard toolbar at the top. In the center of the application
window is the Start Page.
When you load a solution or project, editors and designers appear
in the space where the Start Page is. When you develop an
application, you’ll spend most of your time in this central area.
Visual Studio IDE
19
ToChange the color theme of the IDE
20
Create a simple application
21
Create Simple Console Application
22
Create new Windows FormsApplication
23
Why you should learn
C#
24
Why you should learn C#
 C# and the Visual Studio
IDE make it easy for you to
get to the business of
writing code, and writing it
fast. When you’re working
with C#, the IDE is your
best friend and constant
companion.
25
Visual Studio IDE
26
What you get with Visual Studio and C#…
27
 With a language like C#, tuned for Windows
programming, and the Visual Studio IDE, you can
focus on what your program is supposed to do
immediately:
What you get with Visual Studio and C#…
28
Structure of C-sharp Program-SYNTAX
29
namespace example
{
<class keyword><class Name>
{
<statement 1>;
<statement 2>; //and so on
}
}
Structure of C-sharp Program
30
using System;
class Hello {
static void Main( ) {
Console.WriteLine("Hello world");
Console.ReadLine(); // Hit enter to finish
}
}
Things To Note:
31
 C# is case sensitive.
 All statements and expression 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.
Structure of C-sharp Program
32
The Hello World application is very simple in C#. Some key points:
In C# there are no global methods. Everything belongs to a class.
A method named Main is the entry point for a C# application. Note that Main is spelled with a
capital “M”, which is different than C and C++. The reason is that for consistency, all method
names start with a capital letter in the .NET Framework
The line using System; means that we’ll be accessing members of the System namespace.
In a very rough comparison, a namespace could be translated to a Unit in Turbo Pascal/Delphi
or a .LIB file in C/C++. So in the Hello World example, the class Console, which contains the
method WriteLine belongs to the System namespace. We could avoid the “using” statement
by writing the complete path of the method:
System.Console.WriteLine(“Hello World”);
Simple Console Application-Example
33
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1
{{
class Program
{
{
static void Main(string[] args)
{ {
int a, b;
System.Console.WriteLine("Hello World");
Console.ReadLine();
Console.Write("enter any two numbers");
Console.ReadLine();
a = Convert.ToInt32(Console.ReadLine());
b = Convert.ToInt32(Console.ReadLine());
int sum = a + b;
Console.Write(sum);}}}
}
}
}
Simple Windows Form Application : Example
34
Lecture-2:
Fundamental
concepts of c#
ARRAYS IN C#
Array
Arrays in General
 When declaring an array, the square brackets ([]) must
come after the type, not the identifier. Placing the
brackets after the identifier is not legal syntax in C#.
 int[] table; // not int table[];
38
Arrays in General
The size of the array is not part of its type as it is in the C language.
This allows you to declare an array and assign any array of int objects
to it, regardless of the array's length.
int[] numbers; // declare numbers as an int array of any size
numbers = new int [10]; // numbers is a 10-element array
numbers = new int[20]; // now it's a 20-element array
39
DeclaringArrays
Datatype[] arrayName;
int[] myArray;
String[] names;
40
CreatingArrays
Declaring them (as shown above) does not actually
create the arrays. You need to use the new keyword to
create an instance of the array
int[ ] numbers = newint[5];
double[ ] balance = newdouble[10];
41
Assigning Values to anArray
Note: If you do not initialize an array at the time of declaration, the
array members are automatically initialized to the default initial
value for the array type
You can assign values to individual array elements, by using the
index number, like:
double[] balance = new double[10];
balance[0] = 4500.0
42
Assigning Values to anArray
C# provides simple and straightforward ways to initialize arrays at declaration
time by enclosing the initial values in curly braces({}).
int[ ] numbers = new int[5] {1, 2, 3, 4,5};
string[ ] names = new string[ ] {"Matt", "Joanne","Robert"};
double[ ] balance = { 2340.0, 4523.69,3421.0};
43
Accessing ArrayMembers
static void Main(string[] args)
{
int[] n = new int[10]; int i, j;
//initialize values
for (i = 0; i < 10; i++)
{
n[i] = i + 100;
}
//access elements
for (j = 0; j < 10; j++)
{
Console.WriteLine("Element[{0}] = {1}", j, n[j]);
//Console.ReadKey();
}
}
44
WRITE A PROGRAM IN C# TO GET
VALUES FROM USER TO STORE IT
IN AN ARRAY AND THEN DISPLAY
IT AS OUTPUT.
45
Q#
Lecture-1&2.pdf Visual Programming C# .net framework
foreach loop
The foreach loop is used to iterate over the
elements of the collection. The collection may be
an array or a list. It executes for each element
present in the array.
What is the
difference between
for loop and
foreach loop?
48
for loop executes a statement or
a block of statement until the given
condition is false. Whereas
foreach loop executes a
statement or a block of statements
for each element present in the
array and there is no need to define
the minimum or maximum limit.
we can not obtain array index using
ForEach loop
Using foreach LOOP onArrays
int[] numbers = {4, 5, 6, 1, 2, 3, -2, -1, 0};
foreach (int i in numbers)
{
System.Console.WriteLine(i);
}
Using foreach onArrays
static void Main(string[] args)
{
int[] n = new int[10];
//initialize values
for (int i = 0; i < 10; i++)
{
n[i] = i + 100;
}
//access elements
foreach ( int j in n )
{
int i = j - 100;
Console.WriteLine("Element[{0}] = {1}", i, j);
}
}}}
50
Using foreach onArrays
static void Main(string[] args)
{
char[] myArray = { 'H', 'e', 'l', 'l', 'o' };
foreach (char ch in myArray)
{
Console.WriteLine(ch);
}
Console.Read();
}
51
C# Array Operations using System.Linq
 Min
 Max
 Average
 Sum
 Count
52
Multidimensional
Arrays
53
MultidimensionalArrays
Declaring & initializing Multi-dimensional Arrays
string [,] names;
string[,] names = new string[5,4];
int[,] numbers = new int[3, 2] { {1, 2}, {3, 4}, {5, 6} };
int[,] numbers = new int[,] { {1, 2}, {3, 4}, {5, 6} };
int[,] numbers = { {1, 2}, {3, 4}, {5, 6} };
55

More Related Content

PPT
Visual programming lecture
AqsaHayat3
 
PPTX
Recursion in c++
Abdul Rehman
 
PPT
មេរៀនៈ Data Structure and Algorithm in C/C++
Ngeam Soly
 
PPTX
C# Loops
Hock Leng PUAH
 
PPTX
Computer programming - turbo c environment
John Paul Espino
 
PPTX
Programming Paradigm & Languages
Gaditek
 
PDF
Programming For Problem Solving Lecture Notes
Sreedhar Chowdam
 
PPTX
Ch1 language design issue
Jigisha Pandya
 
Visual programming lecture
AqsaHayat3
 
Recursion in c++
Abdul Rehman
 
មេរៀនៈ Data Structure and Algorithm in C/C++
Ngeam Soly
 
C# Loops
Hock Leng PUAH
 
Computer programming - turbo c environment
John Paul Espino
 
Programming Paradigm & Languages
Gaditek
 
Programming For Problem Solving Lecture Notes
Sreedhar Chowdam
 
Ch1 language design issue
Jigisha Pandya
 

What's hot (20)

DOCX
Training report of C language
Shashank Kapoor
 
DOCX
C Programming
Rumman Ansari
 
PPTX
C# Tutorial
Jm Ramos
 
PDF
Compiler Construction | Lecture 1 | What is a compiler?
Eelco Visser
 
PPT
Compiler Design Unit 1
Jena Catherine Bel D
 
PPT
Visula C# Programming Lecture 1
Abou Bakr Ashraf
 
PPTX
C# programming language
swarnapatil
 
PDF
Fundamental Internet Programming.pdf
Ashenafi Workie
 
PPTX
College Automation System use in Institutions
Nilesh Patil
 
PPTX
Dotnet Basics Presentation
Sudhakar Sharma
 
PDF
C Language
Syed Zaid Irshad
 
PDF
Programming for Problem Solving
Kathirvel Ayyaswamy
 
PPT
.Net Debugging Techniques
Bala Subra
 
PDF
Data representation computer architecture
study cse
 
PPTX
Unit 1.pptx
NISHASOMSCS113
 
PPTX
01. introduction to-programming
Stoian Kirov
 
DOC
Online Attendance Management System
RIDDHICHOUHAN2
 
PPTX
Introduction to C# Programming
Sherwin Banaag Sapin
 
DOCX
Lab manual asp.net
Vivek Kumar Sinha
 
Training report of C language
Shashank Kapoor
 
C Programming
Rumman Ansari
 
C# Tutorial
Jm Ramos
 
Compiler Construction | Lecture 1 | What is a compiler?
Eelco Visser
 
Compiler Design Unit 1
Jena Catherine Bel D
 
Visula C# Programming Lecture 1
Abou Bakr Ashraf
 
C# programming language
swarnapatil
 
Fundamental Internet Programming.pdf
Ashenafi Workie
 
College Automation System use in Institutions
Nilesh Patil
 
Dotnet Basics Presentation
Sudhakar Sharma
 
C Language
Syed Zaid Irshad
 
Programming for Problem Solving
Kathirvel Ayyaswamy
 
.Net Debugging Techniques
Bala Subra
 
Data representation computer architecture
study cse
 
Unit 1.pptx
NISHASOMSCS113
 
01. introduction to-programming
Stoian Kirov
 
Online Attendance Management System
RIDDHICHOUHAN2
 
Introduction to C# Programming
Sherwin Banaag Sapin
 
Lab manual asp.net
Vivek Kumar Sinha
 
Ad

Similar to Lecture-1&2.pdf Visual Programming C# .net framework (20)

PPTX
CS4443 - Modern Programming Language - I Lecture (1)
Dilawar Khan
 
PPTX
01. Introduction to Programming
Intro C# Book
 
PPTX
Introduction to programming using c
Reham Maher El-Safarini
 
PDF
C# c# for beginners crash course master c# programming fast and easy today
Afonso Macedo
 
PDF
Intro to .NET and Core C#
Jussi Pohjolainen
 
PPT
Introduction to Programming Lesson 01
A-Tech and Software Development
 
PPTX
.Net framework
Raghu nath
 
PPT
01 Introduction to programming
maznabili
 
PPTX
Chapter-1 C#.pptx
faarax4
 
PPTX
Advance C# Programming Part 1.pptx
percivalfernandez3
 
PDF
Advance C# Programming Part 1.pdf
percivalfernandez2
 
PDF
C C For Beginners Crash Course Master C Programming Fast And Easy Today Compu...
kasangsadja
 
PPTX
PERTEMUAN 1 - MENGENAL ENVIRONTMENT PROGRAM VISUAL C#.pptx
TriSandhikaJaya
 
PPTX
1. Introduction to C# Programming Langua
KhinLaPyaeWoon1
 
PPT
.NET Overview
Greg Sohl
 
PDF
Introduction to C3.net Architecture unit
Kotresh Munavallimatt
 
PPTX
csharp_dotnet_adnanreza.pptx
Poornima E.G.
 
PPTX
C # (C Sharp).pptx
SnapeSever
 
PPTX
Introduction to .net
Jaya Kumari
 
PPTX
introduction to c #
Sireesh K
 
CS4443 - Modern Programming Language - I Lecture (1)
Dilawar Khan
 
01. Introduction to Programming
Intro C# Book
 
Introduction to programming using c
Reham Maher El-Safarini
 
C# c# for beginners crash course master c# programming fast and easy today
Afonso Macedo
 
Intro to .NET and Core C#
Jussi Pohjolainen
 
Introduction to Programming Lesson 01
A-Tech and Software Development
 
.Net framework
Raghu nath
 
01 Introduction to programming
maznabili
 
Chapter-1 C#.pptx
faarax4
 
Advance C# Programming Part 1.pptx
percivalfernandez3
 
Advance C# Programming Part 1.pdf
percivalfernandez2
 
C C For Beginners Crash Course Master C Programming Fast And Easy Today Compu...
kasangsadja
 
PERTEMUAN 1 - MENGENAL ENVIRONTMENT PROGRAM VISUAL C#.pptx
TriSandhikaJaya
 
1. Introduction to C# Programming Langua
KhinLaPyaeWoon1
 
.NET Overview
Greg Sohl
 
Introduction to C3.net Architecture unit
Kotresh Munavallimatt
 
csharp_dotnet_adnanreza.pptx
Poornima E.G.
 
C # (C Sharp).pptx
SnapeSever
 
Introduction to .net
Jaya Kumari
 
introduction to c #
Sireesh K
 
Ad

Recently uploaded (20)

PPTX
PPTs-The Rise of Empiresghhhhhhhh (1).pptx
academysrusti114
 
PPTX
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
DOCX
UPPER GASTRO INTESTINAL DISORDER.docx
BANDITA PATRA
 
PPTX
vedic maths in python:unleasing ancient wisdom with modern code
mistrymuskan14
 
PDF
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
PPTX
Care of patients with elImination deviation.pptx
AneetaSharma15
 
PPTX
Software Engineering BSC DS UNIT 1 .pptx
Dr. Pallawi Bulakh
 
PPTX
CARE OF UNCONSCIOUS PATIENTS .pptx
AneetaSharma15
 
PPTX
Open Quiz Monsoon Mind Game Final Set.pptx
Sourav Kr Podder
 
PPTX
Nursing Management of Patients with Disorders of Ear, Nose, and Throat (ENT) ...
RAKESH SAJJAN
 
PDF
Module 3: Health Systems Tutorial Slides S2 2025
Jonathan Hallett
 
PPTX
NOI Hackathon - Summer Edition - GreenThumber.pptx
MartinaBurlando1
 
PPTX
Strengthening open access through collaboration: building connections with OP...
Jisc
 
PDF
UTS Health Student Promotional Representative_Position Description.pdf
Faculty of Health, University of Technology Sydney
 
PPTX
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
DOCX
Action Plan_ARAL PROGRAM_ STAND ALONE SHS.docx
Levenmartlacuna1
 
DOCX
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 
PPTX
Understanding operators in c language.pptx
auteharshil95
 
PPTX
Congenital Hypothyroidism pptx
AneetaSharma15
 
PPTX
IMMUNIZATION PROGRAMME pptx
AneetaSharma15
 
PPTs-The Rise of Empiresghhhhhhhh (1).pptx
academysrusti114
 
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
UPPER GASTRO INTESTINAL DISORDER.docx
BANDITA PATRA
 
vedic maths in python:unleasing ancient wisdom with modern code
mistrymuskan14
 
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
Care of patients with elImination deviation.pptx
AneetaSharma15
 
Software Engineering BSC DS UNIT 1 .pptx
Dr. Pallawi Bulakh
 
CARE OF UNCONSCIOUS PATIENTS .pptx
AneetaSharma15
 
Open Quiz Monsoon Mind Game Final Set.pptx
Sourav Kr Podder
 
Nursing Management of Patients with Disorders of Ear, Nose, and Throat (ENT) ...
RAKESH SAJJAN
 
Module 3: Health Systems Tutorial Slides S2 2025
Jonathan Hallett
 
NOI Hackathon - Summer Edition - GreenThumber.pptx
MartinaBurlando1
 
Strengthening open access through collaboration: building connections with OP...
Jisc
 
UTS Health Student Promotional Representative_Position Description.pdf
Faculty of Health, University of Technology Sydney
 
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
Action Plan_ARAL PROGRAM_ STAND ALONE SHS.docx
Levenmartlacuna1
 
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 
Understanding operators in c language.pptx
auteharshil95
 
Congenital Hypothyroidism pptx
AneetaSharma15
 
IMMUNIZATION PROGRAMME pptx
AneetaSharma15
 

Lecture-1&2.pdf Visual Programming C# .net framework

  • 2. Prerequisites  This module assumes that you understand the fundamentals of  Programming  Variables, statements, functions, loops, etc.  Object-oriented programming  Classes, inheritance, polymorphism, members, etc.  C++ or Java 2
  • 3. 3 Lecture Plan  Introduction to thecourse  Configure the Microsoft Visual StudioIDE  Create a simple hello world style application  MessageBox
  • 4. Introduction to the course 1 Course Objectives Todevelopment of Interactive applications Toenable student to write event drivenprograms Todevelopment of GUIapplications Grading Quizzes/Assignments = 30% Mid-termexams = 20% Final-termexams = 50%
  • 6. What is .NET Framework 6 ✗ Net Framework is a software development platform developed by Microsoft for building and running Windows applications. ✗ The . Net framework consists of developer tools, programming languages, and libraries to build desktop and web applications. It is also used to build websites, web services, and games.
  • 7. What is .NET Framework 7 There are various implementations of .NET. 1. NET Framework is the original implementation of .NET. It supports running websites, services, desktop apps, and more on Windows. 2. NET is a cross-platform implementation for running websites, services, and console apps on Windows, Linux, and macOS. .NET is open source on GitHub. .NET was previously called .NET Core. 3. Xamarin/Mono is a .NET implementation for running apps on all the major mobile operating systems, including iOS and Android
  • 11. Architecture of .NET Framework 11 The two major components of .NET Framework are the Common Language Runtime and the .NET Framework Class Library. The Common Language Runtime (CLR) is the execution engine that handles running applications. It provides services like thread management, garbage collection, type-safety, exception handling, and more. The Class Library provides a set of APIs and types for common functionality. It provides types for strings, dates, numbers, etc. The Class Library includes APIs for reading and writing files, connecting to databases, drawing, and more.
  • 12. Architecture of .NET Framework 12 ✗ .NET applications are written in the C#, F#, or Visual Basic programming language. Code is compiled into a language-agnostic Common Intermediate Language (CIL). Compiled code is stored in assemblies—files with a .dll or .exe file extension. ✗ When an app runs, the CLR takes the assembly and uses a just-in-time compiler (JIT) to turn it into machine code that can execute on the specific architecture of the computer it is running on.
  • 13. .NET Components : Common Language Runtime 13 Common Language Runtime The “Common Language Infrastructure” or CLI is a platform in dot-Net architecture on which the dot-Net programs are executed. The CLI has the following key features: Exception Handling – Exceptions are errors which occur when the application is executed. Examples of exceptions are: • If an application tries to open a file on the local machine, but the file is not present. • If the application tries to fetch some records from a database, but the connection to the database is not valid.
  • 14. .NET Components : Common Language Runtime 14 Garbage Collection – Garbage collection is the process of removing unwanted resources when they are no longer required. Examples of garbage collection are • A File handle which is no longer required. If the application has finished all operations on a file, then the file handle may no longer be required. • The database connection is no longer required. If the application has finished all operations on a database, then the database connection may no longer be required.
  • 15. .NET Components : Common Language Runtime 15 A developer can develop an application in a variety of .Net programming languages. 1. Language – The first level is the programming language itself, the most common ones are VB.Net and C#. 2. Compiler – There is a compiler which will be separate for each programming language. So underlying the VB.Net language, there will be a separate VB.Net compiler. Similarly, for C#, you will have another compiler. 3. Common Language Interpreter – This is the final layer in .Net which would be used to run a .net program developed in any programming language. So the subsequent compiler will send the program to the CLI layer to run the .Net application.
  • 16. Architecture of .NET Framework 16 The two major components of .NET Framework are the Common Language Runtime and the .NET Framework Class Library. The Common Language Runtime (CLR) is the execution engine that handles running applications. It provides services like thread management, garbage collection, type-safety, exception handling, and more. The Class Library provides a set of APIs and types for common functionality. It provides types for strings, dates, numbers, etc. The Class Library includes APIs for reading and writing files, connecting to databases, drawing, and more.
  • 17. Architecture of .NET Framework 17 ✗ .NET applications are written in the C#, F#, or Visual Basic programming language. Code is compiled into a language-agnostic Common Intermediate Language (CIL). Compiled code is stored in assemblies—files with a .dll or .exe file extension. ✗ When an app runs, the CLR takes the assembly and uses a just-in-time compiler (JIT) to turn it into machine code that can execute on the specific architecture of the computer it is running on.
  • 18. Configure the IDE 18  After you open Visual Studio, you can identify the tool windows, the menus and toolbars, and the main window space. Tool windows are docked on the left and right sides of the application window, with Quick Launch, the menu bar, and the standard toolbar at the top. In the center of the application window is the Start Page. When you load a solution or project, editors and designers appear in the space where the Start Page is. When you develop an application, you’ll spend most of your time in this central area.
  • 20. ToChange the color theme of the IDE 20
  • 21. Create a simple application 21
  • 22. Create Simple Console Application 22
  • 23. Create new Windows FormsApplication 23
  • 24. Why you should learn C# 24
  • 25. Why you should learn C#  C# and the Visual Studio IDE make it easy for you to get to the business of writing code, and writing it fast. When you’re working with C#, the IDE is your best friend and constant companion. 25
  • 27. What you get with Visual Studio and C#… 27  With a language like C#, tuned for Windows programming, and the Visual Studio IDE, you can focus on what your program is supposed to do immediately:
  • 28. What you get with Visual Studio and C#… 28
  • 29. Structure of C-sharp Program-SYNTAX 29 namespace example { <class keyword><class Name> { <statement 1>; <statement 2>; //and so on } }
  • 30. Structure of C-sharp Program 30 using System; class Hello { static void Main( ) { Console.WriteLine("Hello world"); Console.ReadLine(); // Hit enter to finish } }
  • 31. Things To Note: 31  C# is case sensitive.  All statements and expression 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.
  • 32. Structure of C-sharp Program 32 The Hello World application is very simple in C#. Some key points: In C# there are no global methods. Everything belongs to a class. A method named Main is the entry point for a C# application. Note that Main is spelled with a capital “M”, which is different than C and C++. The reason is that for consistency, all method names start with a capital letter in the .NET Framework The line using System; means that we’ll be accessing members of the System namespace. In a very rough comparison, a namespace could be translated to a Unit in Turbo Pascal/Delphi or a .LIB file in C/C++. So in the Hello World example, the class Console, which contains the method WriteLine belongs to the System namespace. We could avoid the “using” statement by writing the complete path of the method: System.Console.WriteLine(“Hello World”);
  • 33. Simple Console Application-Example 33 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp1 {{ class Program { { static void Main(string[] args) { { int a, b; System.Console.WriteLine("Hello World"); Console.ReadLine(); Console.Write("enter any two numbers"); Console.ReadLine(); a = Convert.ToInt32(Console.ReadLine()); b = Convert.ToInt32(Console.ReadLine()); int sum = a + b; Console.Write(sum);}}} } } }
  • 34. Simple Windows Form Application : Example 34
  • 37. Array
  • 38. Arrays in General  When declaring an array, the square brackets ([]) must come after the type, not the identifier. Placing the brackets after the identifier is not legal syntax in C#.  int[] table; // not int table[]; 38
  • 39. Arrays in General The size of the array is not part of its type as it is in the C language. This allows you to declare an array and assign any array of int objects to it, regardless of the array's length. int[] numbers; // declare numbers as an int array of any size numbers = new int [10]; // numbers is a 10-element array numbers = new int[20]; // now it's a 20-element array 39
  • 41. CreatingArrays Declaring them (as shown above) does not actually create the arrays. You need to use the new keyword to create an instance of the array int[ ] numbers = newint[5]; double[ ] balance = newdouble[10]; 41
  • 42. Assigning Values to anArray Note: If you do not initialize an array at the time of declaration, the array members are automatically initialized to the default initial value for the array type You can assign values to individual array elements, by using the index number, like: double[] balance = new double[10]; balance[0] = 4500.0 42
  • 43. Assigning Values to anArray C# provides simple and straightforward ways to initialize arrays at declaration time by enclosing the initial values in curly braces({}). int[ ] numbers = new int[5] {1, 2, 3, 4,5}; string[ ] names = new string[ ] {"Matt", "Joanne","Robert"}; double[ ] balance = { 2340.0, 4523.69,3421.0}; 43
  • 44. Accessing ArrayMembers static void Main(string[] args) { int[] n = new int[10]; int i, j; //initialize values for (i = 0; i < 10; i++) { n[i] = i + 100; } //access elements for (j = 0; j < 10; j++) { Console.WriteLine("Element[{0}] = {1}", j, n[j]); //Console.ReadKey(); } } 44
  • 45. WRITE A PROGRAM IN C# TO GET VALUES FROM USER TO STORE IT IN AN ARRAY AND THEN DISPLAY IT AS OUTPUT. 45 Q#
  • 47. foreach loop The foreach loop is used to iterate over the elements of the collection. The collection may be an array or a list. It executes for each element present in the array.
  • 48. What is the difference between for loop and foreach loop? 48 for loop executes a statement or a block of statement until the given condition is false. Whereas foreach loop executes a statement or a block of statements for each element present in the array and there is no need to define the minimum or maximum limit. we can not obtain array index using ForEach loop
  • 49. Using foreach LOOP onArrays int[] numbers = {4, 5, 6, 1, 2, 3, -2, -1, 0}; foreach (int i in numbers) { System.Console.WriteLine(i); }
  • 50. Using foreach onArrays static void Main(string[] args) { int[] n = new int[10]; //initialize values for (int i = 0; i < 10; i++) { n[i] = i + 100; } //access elements foreach ( int j in n ) { int i = j - 100; Console.WriteLine("Element[{0}] = {1}", i, j); } }}} 50
  • 51. Using foreach onArrays static void Main(string[] args) { char[] myArray = { 'H', 'e', 'l', 'l', 'o' }; foreach (char ch in myArray) { Console.WriteLine(ch); } Console.Read(); } 51
  • 52. C# Array Operations using System.Linq  Min  Max  Average  Sum  Count 52
  • 55. Declaring & initializing Multi-dimensional Arrays string [,] names; string[,] names = new string[5,4]; int[,] numbers = new int[3, 2] { {1, 2}, {3, 4}, {5, 6} }; int[,] numbers = new int[,] { {1, 2}, {3, 4}, {5, 6} }; int[,] numbers = { {1, 2}, {3, 4}, {5, 6} }; 55