SlideShare a Scribd company logo
1 of 55
Download to read offline
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#
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

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

LECTURE 1 - Introduction to Programming.pptx
LECTURE 1 - Introduction to Programming.pptxLECTURE 1 - Introduction to Programming.pptx
LECTURE 1 - Introduction to Programming.pptxAOmaAli
 
COM1407: Introduction to C Programming
COM1407: Introduction to C Programming COM1407: Introduction to C Programming
COM1407: Introduction to C Programming Hemantha Kulathilake
 
01 Introduction to programming
01 Introduction to programming01 Introduction to programming
01 Introduction to programmingmaznabili
 
INTRODUCTION TO C PROGRAMMING MATERIAL.pdf
INTRODUCTION TO C PROGRAMMING MATERIAL.pdfINTRODUCTION TO C PROGRAMMING MATERIAL.pdf
INTRODUCTION TO C PROGRAMMING MATERIAL.pdfSubramanyambharathis
 
tybsc it asp.net full unit 1,2,3,4,5,6 notes
tybsc it asp.net full unit 1,2,3,4,5,6 notestybsc it asp.net full unit 1,2,3,4,5,6 notes
tybsc it asp.net full unit 1,2,3,4,5,6 notesWE-IT TUTORIALS
 
Chapter 1 - Basic concepts of programming.pdf
Chapter 1 - Basic concepts of programming.pdfChapter 1 - Basic concepts of programming.pdf
Chapter 1 - Basic concepts of programming.pdfKirubelWondwoson1
 
Chapter-1 C#.pptx
Chapter-1 C#.pptxChapter-1 C#.pptx
Chapter-1 C#.pptxfaarax4
 
Introduction to Computer Programming (general background)
Introduction to Computer Programming (general background)Introduction to Computer Programming (general background)
Introduction to Computer Programming (general background)Chao-Lung Yang
 
C# lecture 1: Introduction to Dot Net Framework
C# lecture 1: Introduction to Dot Net FrameworkC# lecture 1: Introduction to Dot Net Framework
C# lecture 1: Introduction to Dot Net FrameworkDr.Neeraj Kumar Pandey
 
01. introduction to-programming
01. introduction to-programming01. introduction to-programming
01. introduction to-programmingStoian Kirov
 
.NET Core, ASP.NET Core Course, Session 3
.NET Core, ASP.NET Core Course, Session 3.NET Core, ASP.NET Core Course, Session 3
.NET Core, ASP.NET Core Course, Session 3aminmesbahi
 
CS8251_QB_answers.pdf
CS8251_QB_answers.pdfCS8251_QB_answers.pdf
CS8251_QB_answers.pdfvino108206
 
Dotnet Basics Presentation
Dotnet Basics PresentationDotnet Basics Presentation
Dotnet Basics PresentationSudhakar Sharma
 

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

LECTURE 1 - Introduction to Programming.pptx
LECTURE 1 - Introduction to Programming.pptxLECTURE 1 - Introduction to Programming.pptx
LECTURE 1 - Introduction to Programming.pptx
 
COM1407: Introduction to C Programming
COM1407: Introduction to C Programming COM1407: Introduction to C Programming
COM1407: Introduction to C Programming
 
01 Introduction to programming
01 Introduction to programming01 Introduction to programming
01 Introduction to programming
 
INTRODUCTION TO C PROGRAMMING MATERIAL.pdf
INTRODUCTION TO C PROGRAMMING MATERIAL.pdfINTRODUCTION TO C PROGRAMMING MATERIAL.pdf
INTRODUCTION TO C PROGRAMMING MATERIAL.pdf
 
Dotnet basics
Dotnet basicsDotnet basics
Dotnet basics
 
tybsc it asp.net full unit 1,2,3,4,5,6 notes
tybsc it asp.net full unit 1,2,3,4,5,6 notestybsc it asp.net full unit 1,2,3,4,5,6 notes
tybsc it asp.net full unit 1,2,3,4,5,6 notes
 
Dot net
Dot netDot net
Dot net
 
Chapter 1 - Basic concepts of programming.pdf
Chapter 1 - Basic concepts of programming.pdfChapter 1 - Basic concepts of programming.pdf
Chapter 1 - Basic concepts of programming.pdf
 
Chapter-1 C#.pptx
Chapter-1 C#.pptxChapter-1 C#.pptx
Chapter-1 C#.pptx
 
Introduction to Programming Lesson 01
Introduction to Programming Lesson 01Introduction to Programming Lesson 01
Introduction to Programming Lesson 01
 
Introduction to Computer Programming (general background)
Introduction to Computer Programming (general background)Introduction to Computer Programming (general background)
Introduction to Computer Programming (general background)
 
C# lecture 1: Introduction to Dot Net Framework
C# lecture 1: Introduction to Dot Net FrameworkC# lecture 1: Introduction to Dot Net Framework
C# lecture 1: Introduction to Dot Net Framework
 
Introduction to .net
Introduction to .netIntroduction to .net
Introduction to .net
 
01. introduction to-programming
01. introduction to-programming01. introduction to-programming
01. introduction to-programming
 
C++Basics2022.pptx
C++Basics2022.pptxC++Basics2022.pptx
C++Basics2022.pptx
 
Unit 2 ppt
Unit 2 pptUnit 2 ppt
Unit 2 ppt
 
.NET Core, ASP.NET Core Course, Session 3
.NET Core, ASP.NET Core Course, Session 3.NET Core, ASP.NET Core Course, Session 3
.NET Core, ASP.NET Core Course, Session 3
 
CS8251_QB_answers.pdf
CS8251_QB_answers.pdfCS8251_QB_answers.pdf
CS8251_QB_answers.pdf
 
Intro1
Intro1Intro1
Intro1
 
Dotnet Basics Presentation
Dotnet Basics PresentationDotnet Basics Presentation
Dotnet Basics Presentation
 

Recently uploaded

Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Planning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxPlanning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxLigayaBacuel1
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxsqpmdrvczh
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 

Recently uploaded (20)

Rapple "Scholarly Communications and the Sustainable Development Goals"
Rapple "Scholarly Communications and the Sustainable Development Goals"Rapple "Scholarly Communications and the Sustainable Development Goals"
Rapple "Scholarly Communications and the Sustainable Development Goals"
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Planning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxPlanning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptx
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptx
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 

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#
  • 46.
  • 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