SlideShare una empresa de Scribd logo
1 de 62
Descargar para leer sin conexión
Diploma in Information Technology
Module IX: Programming with
C#.NET
Rasan Samarasinghe
ESOFT Computer Studies (pvt) Ltd.
No 68/1, Main Street, Pallegama, Embilipitiya.
Contents
1. Introduction to .NET Framework
2. .NET Framework Platform Architecture
3. Microsoft Visual Studio
4. C# Language
5. C#, VS and .NET Framework Versions
6. Your First C# Application
7. Printing Statements
8. Comments in C#
9. Common Type System
10. Value Types and Reference Type
11. Variables Declaration in C#
12. Type Conversion
13. Arithmetic Operators
14. Assignment Operators
15. Comparison Operators
16. Logical Operators
17. If Statement
18. If… Else Statement
19. If… Else if… Else Statement
20. Nested If Statement
21. Switch Statement
22. While Loop
23. Do While Loop
23. For Loop
24. Arrays
25. Accessing Arrays using foreach Loop
26. Two Dimensional Arrays
27. Classes and Objects in C#
28. Inheritance in C#
29. Partial Classes
30. Namespaces
31. Windows Forms Applications
32. Using Buttons, Labels and Text Boxes
33. Displaying Message Boxes
34. Error Handling with Try… Catch… finally…
35. Using Radio Buttons
36. Using Check Boxes
37. Using List Boxes
38. Creating Menus
39. Creating ToolStrips
40. MDI Forms
41. Database Application in C#
42. Creating a Simple Database Application
43. SQL Insert / Update / Retrieving / Delete
44. SQL Command Execute Methods
45. Data Sets
Introduction to .NET Framework
• The .NET Framework is a software
framework developed by Microsoft
that runs primarily on Microsoft
Windows.
• It includes a large library and provides
language interoperability across
several programming languages.
• Programs written for .NET Framework
execute in a software environment
known as CLR.
• .NET Framework is intended to be
used by most new applications
created for the Windows platform.
.NET Framework Platform Architecture
Microsoft Visual Studio
• Microsoft Visual Studio is an integrated development
environment (IDE) from Microsoft…
• To develop Windows Forms or WPF applications, web
sites, web applications, and web services…
• For Microsoft Windows, Windows Mobile, Windows
CE, .NET Framework and Microsoft Silverlight.
C# Language
C# is a general purpose, object oriented
programming language developed by Microsoft
within its .NET initiative led by Anders Hejlsberg.
C# Language Features
• Boolean Conditions
• Automatic Garbage Collection
• Standard Library
• Assembly Versioning
• Properties and Events
• Delegates and Events Management
• Easy-to-use Generics
• Indexers
• Conditional Compilation
• Simple Multithreading
• LINQ and Lambda Expressions
• Integration with Windows
C#, VS and .NET Framework Versions
C# Version Visual Studio Version .NET Framework Version
C# 1.0 Visual Studio .NET 2002 .NET Framework 1.0
C# 1.2 Visual Studio .NET 2003 .NET Framework 1.1
C# 2.0 Visual Studio 2005 .NET Framework 2.0
C# 3.0
Visual Studio 2008
Visual Studio 2010
.NET Framework 2.0
.NET Framework 3.0
.NET Framework 3.5
C# 4.0 Visual Studio 2010 .NET Framework 4
C# 5.0
Visual Studio 2012
Visual Studio 2013
.NET Framework 4.5
Your First C# Application
using System;
namespace myspace
{
class FirstApp
{
static void Main()
{
Console.WriteLine(“Hello World!”);
}
}
}
Printing Statements
Console.Write(“Hello World!”); //prints a text
Console.WriteLine(“Hello World!”); //prints text and
starts a new line
Console.Write(“Hello nWorld!”); //line breaks
Console.Write(“Hello {0}”, “Esoft”); //variable
displaying
Comments in C#
Single line comments
// this is a single line comment
Multiline comments
/*
this is
a multiline
comment
*/
Common Type System
Value Types and Reference Type
Predefined Value Types
sbyte -128 to 127 8 bits
byte 0 to 255 8 bits
short -32,768 to 32,767 16 bits
ushort 0 to 65,535 16 bits
int -2,147,483,648 to 2,147,483,647 32 bits
uint 0 to 4,294,967,295 32 bits
long -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 64 bits
ulong 0 to 18,446,744,073,709,551,615 64 bits
char 16 bit Unicode character 16 bits
float -3.4 x 1038 to + 3.4 x 1038 32 bits
double (+/-)5.0 x 10-324 to (+/-) 1.7 x 10308 64 bits
decimal (-7.9 x 1028 to 7.9 x 1028) / 100 to 28 128 bits
bool Holds true or false 1 bit
Predefined Reference Types
string Represents a string of Unicode characters 20+ bits
object Represents a general purpose type 8+ bits
Variable Declaration in C#
Variable declaration
type variable_list;
Variable declaration and initialization
type variable_name = value;
Variable Declaration in C#
int a, b, c; // declares three ints, a, b, and c.
int d = 3, e, f = 5; // declares three more ints,
initializing d and f.
bool z = 5>2; // declares and initializes z.
double pi = 3.14159; // declares an approximation
of pi.
char x = 'x'; // the variable x has the value 'x'.
Type Conversion
• Implicit Conversion
– No special syntax is required because the
conversion is type safe and no data will be lost.
• Explicit Conversion
– Require a cast operator, and information might be
lost in the conversion.
• Conversions with helper classes
– To convert between non-compatible types.
Implicit Conversion
int x = 123;
double y = x;
Explicit Conversion
double y = 123.5;
int x = (int)y;
Conversions with helper classes
String x = "123";
int y = Int.Parse(x);
int z = Convert.ToInt32(x);
Arithmetic Operators
Operator Description Example
+ Addition X + Y will give 60
- Subtraction X - Y will give -20
* Multiplication X * Y will give 800
/ Division Y / X will give 2
% Modulus Y % X will give 0
++ Increment Y++ gives 41
-- Decrement Y-- gives 39
X = 20, Y = 40
Assignment Operators
Operator Example
= Z = X + Y will assign value of X + Y into Z
+= Z += X is equivalent to Z = Z + X
-= Z -= X is equivalent to Z = Z - X
*= Z *= X is equivalent to Z = Z * X
/= Z /= X is equivalent to Z = Z / X
%= Z %= X is equivalent to Z = Z % X
Comparison Operators
Operator Example
== (X == Y) is false.
!= (X != Y) is true.
> (X > Y) is false.
< (X < Y) is true.
>= (X >= Y) is false.
<= (X <= Y) is true.
X = 50, Y = 70
Logical Operators
Operator Name Example
&& AND (X && Y) is False
|| OR (X || Y) is True
! NOT !(X && Y) is True
X = True, Y = False
If Statement
if(Boolean_expression)
{
// Statements will execute if the
Boolean expression is true
}
Boolean
Expression
Statements
True
False
If… Else Statement
if(Boolean_expression)
{
// Executes when the Boolean expression is
true
}
else
{
// Executes when the Boolean
expression is false
}
Boolean
Expression
Statements
True
False
Statements
If… Else if… Else Statement
if(Boolean_expression 1)
{
// Executes when the Boolean expression 1 is true
}
else if(Boolean_expression 2)
{
// Executes when the Boolean expression 2 is true
}
else if(Boolean_expression 3)
{
// Executes when the Boolean expression 3 is true
}
else
{
// Executes when the none of the above condition is true.
}
If… Else if… Else Statement
Boolean
expression 1
False
Statements
Boolean
expression 2
Boolean
expression 3
Statements
Statements
False
False
Statements
True
True
True
Nested If Statement
if(Boolean_expression 1)
{
// Executes when the Boolean expression 1 is
true
if(Boolean_expression 2)
{
// Executes when the Boolean expression 2 is
true
}
}
Boolean
Expression 1
True
False
Statements
Boolean
Expression 2
True
False
Switch Statement
switch (value)
{
case constant:
// statements
break;
case constant:
// statements
break;
default:
// statements
break;
}
While Loop
while(Boolean_expression)
{
// Statements
}
Boolean
Expression
Statements
True
False
Do While Loop
do
{
// Statements
}while(Boolean_expression);
Boolean
Expression
Statements
True
False
For Loop
for(initialization; Boolean_expression; update)
{
// Statements
}
Boolean
Expression
Statements
True
False
Update
Initialization
Arrays
10 30 20 50 15 35
0 1 2 3 4 5
Size = 6
Element Index No
An Array can hold many values in a same
data type under a single name
A single dimensional array
Building a Single Dimensional Array
// creating an Array
DataType[] ArrayName = new DataType[size];
// assigning values
ArrayName[index] = value;
ArrayName[index] = value;
……..
Building a Single Dimensional Array
char[] letters = new char[4];
letters[0] = ‘O’;
letters[1] = ‘P’;
letters[2] = ‘Q’;
letters[3] = ‘R’;
0 1 2 3
O P Q R
0 1 2 3
letters
letters
Values in an Array can access
by referring index number
Building a Single Dimensional Array
// creating an array using array initializer
DataType[] ArrayName = {element 1, element 2,
element 3, … element n};
int[] marks = {10, 20, 30, 40, 50}; 10 20 30 40
0 1 2 3
intArr
50
4
Accessing Arrays using foreach Loop
// creating an Array
int[] marks = {10, 29, 30, 40, 50, 70};
// accessing array elements
foreach(int n in marks)
{
System.Console.WriteLine(n);
}
Two Dimensional Arrays
5 10 15
25 50 75
0 1 2
0
1
int[,] myMatrix = new int[2,3];
myMatrix[0,0] = 5;
myMatrix[0,1] = 10;
myMatrix[0,2] = 15;
myMatrix[1,0] = 25;
myMatrix[1,1] = 50;
myMatrix[1,2] = 75;
Rows Columns
Column Index
Row Index
Two Dimensional Arrays
Using array initializer…
int[,] myMatrix = new int[2,3] {{5,10,15},{25,50,75}};
int[,] myMatrix = {{5,10,15},{25,50,75}};
Or
Classes and Objects in C#
Method
Student
name
age
Register()
class Student
{
public String name;
public int age;
public Student(){
}
public void Register(){
Console.WriteLine(“Registered!”);
}
}
Attributes
Constructor
C# Objects
Student st = new Student(); //creating an object
//Assigning values to Attributes
st.name = “Roshan”;
st.age = 20;
//calling method
st.Register();
Inheritance in C#
class Animal
{
//attributes and methods
}
class Lion : Animal
{
//attributes and methods
}
class Cat : Animal
{
//attributes and methods
}
Animal
Lion Cat
Partial Classes
partial class Student
{
public int age;
}
partial class Student
{
public String name;
}
partial class Student
{
public String address;
public void Register(){
Console.Write("Student Registered");
}
}
Partials of the same class
Namespaces
• Namespace is an
organization construct.
• It’s a group of collected
types.
• It’s helping to
understand how the
code base is arranged.
• Namespaces are not
essential for C#
programs.
namespace esoft
{
class ditec{
}
class dise{
}
}
Importing Namespaces
Importing Namespace by using “using” directive
using System.Linq;
Importing Namespace with alias directive
using ns = System.Linq;
Direct accessing Namespaces
System.Console.WriteLine(“hello”);
Windows Forms Applications
• A Windows Forms application is an event-
driven application supported by Microsoft's
.NET Framework.
• This model provides object-oriented,
extensible set of classes that enable you to
develop rich Windows applications.
Using Button, Labels and Text Boxes
private void button1_Click(object sender, EventArgs e)
{
label2.Text = "Welcome " + textBox1.Text;
}
Displaying Message Boxes
MessageBox.Show("Hello World","MessageBox Demo",MessageBoxButtons.YesNo,
MessageBoxIcon.Information);
MessageBox.Show("Hello World“);
Error Handling with Try… Catch… finally…
try
{
//Protected code
}
catch (Exception ex)
{
//Catch block
}
finally
{
//The finally block always executes
}
Using Radio Buttons
private void button1_Click(object sender, EventArgs e)
{
if (radioButton1.Checked)
{
MessageBox.Show("You have chosen Black");
}
else
{
MessageBox.Show("You have chosen White");
}
}
Using Check Boxes
private void button1_Click(object sender, EventArgs e)
{
if (checkBox1.Checked)
{
MessageBox.Show("You have accepted Terms of Agreement");
}
else
{
MessageBox.Show("You haven't accepted Terms of Agreement");
}
}
Using List Boxes
Statements for each button click events
listBox1.Items.Add(textBox1.Text);
listBox1.Items.AddRange(new String[] {
“America", “Japan", “India" });
listBox1.Items.Insert(0, textBox1.Text);
listBox1.Items.Remove(listBox1.SelectedItem);
listBox1.Items.RemoveAt(int.Parse(textBox1.Text
));
listBox1.Items.Clear();
listBox1.Sorted = true;
Creating Menus
private void newToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("You have clicked New Menu item!");
}
Creating ToolStrips
private void newToolStripButton_Click(object sender, EventArgs e)
{
MessageBox.Show("You have clicked newToolStripButton!");
}
MDI Forms
private void document1ToolStripMenuItem_Click(object sender, EventArgs e)
{
Document_One form1 = new Document_One();
form1.MdiParent = this;
form1.Show();
}
Database Application in C#
Application DataBase
Insert, Update, Retrieving
and Delete Processes
Creating a Simple Database Application
Creating a simple database application involved with
following steps.
1. Import the namespaces
2. Creating a SQL Connection
3. Open SQL Connection
4. Create a SQL Command
5. Execute the SQL Command
6. Extract data from SQL Data Reader
7. Clean up the environment
Creating a Simple Database Application
using System;
using System.Data.SqlClient;
class Program
{
static void Main(string[] args)
{
SqlConnection con = new SqlConnection("Data Source=.SQLEXPRESS; Initial Catalog=esoftdb;
Integrated Security=yes");
con.Open();
SqlCommand cmd = new SqlCommand("SELECT * FROM tblStudent", con);
SqlDataReader rd = cmd.ExecuteReader();
while (rd.Read())
{
Console.Write(rd["id"].ToString() + " ");
Console.Write(rd["name"].ToString() + " ");
Console.WriteLine(rd["address"].ToString());
}
rd.Close();
con.Close();
Console.ReadLine();
}
}
1
2
3
4
5
6
7
SQL Insert / Update / Retrieving / Delete
Inserting Data into Database
SqlCommand cmd = new SqlCommand(“INSERT tblStudent VALUES(1, ‘Roshan’,
‘Colombo’)", con);
Updating Data in Database
SqlCommand cmd = new SqlCommand(“UPDATE tblStudent SET address=‘kandy’
WHERE id=1", con);
Retrieving Data from Database
SqlCommand cmd = new SqlCommand("SELECT * FROM tblStudent", con);
Deleting Data in Database
SqlCommand cmd = new SqlCommand(“DELETE FROM tblStudent WHERE id=1",
con);
SQL Command Execute Methods
• ExecuteNonQuery() : Executes a Transact-SQL statement against
the connection and returns the number of rows affected.
• ExecuteReader() : Sends the CommandText to the Connection and
builds a SqlDataReader.
• ExecuteScalar() : Executes the query, and returns the first column of
the first row in the result set returned by the query.
int n = cmd.ExecuteNonQuery();
SqlDataReader rd = cmd.ExecuteReader();
String name= cmd.ExecuteScalar();
Data Sets
Represents an in-memory cache of data.
SqlConnection con = new SqlConnection("Data Source=.SQLEXPRESS; Initial
Catalog=esoftdb; Integrated Security=yes");
SqlCommand cmd = new SqlCommand("SELECT * FROM tblStudent", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds, “tblStudent”);
The End
http://twitter.com/rasansmn

Más contenido relacionado

La actualidad más candente

Introduction to Client-Side Javascript
Introduction to Client-Side JavascriptIntroduction to Client-Side Javascript
Introduction to Client-Side JavascriptJulie Iskander
 
03 and 04 .Operators, Expressions, working with the console and conditional s...
03 and 04 .Operators, Expressions, working with the console and conditional s...03 and 04 .Operators, Expressions, working with the console and conditional s...
03 and 04 .Operators, Expressions, working with the console and conditional s...Intro C# Book
 
Visula C# Programming Lecture 2
Visula C# Programming Lecture 2Visula C# Programming Lecture 2
Visula C# Programming Lecture 2Abou Bakr Ashraf
 
Qcon2011 functions rockpresentation_f_sharp
Qcon2011 functions rockpresentation_f_sharpQcon2011 functions rockpresentation_f_sharp
Qcon2011 functions rockpresentation_f_sharpMichael Stal
 
JAVA Variables and Operators
JAVA Variables and OperatorsJAVA Variables and Operators
JAVA Variables and OperatorsSunil OS
 
Oop2010 Scala Presentation Stal
Oop2010 Scala Presentation StalOop2010 Scala Presentation Stal
Oop2010 Scala Presentation StalMichael Stal
 
Visula C# Programming Lecture 7
Visula C# Programming Lecture 7Visula C# Programming Lecture 7
Visula C# Programming Lecture 7Abou Bakr Ashraf
 
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]Chris Adamson
 
Type Classes in Scala and Haskell
Type Classes in Scala and HaskellType Classes in Scala and Haskell
Type Classes in Scala and HaskellHermann Hueck
 
Domain Driven Design with the F# type System -- F#unctional Londoners 2014
Domain Driven Design with the F# type System -- F#unctional Londoners 2014Domain Driven Design with the F# type System -- F#unctional Londoners 2014
Domain Driven Design with the F# type System -- F#unctional Londoners 2014Scott Wlaschin
 

La actualidad más candente (20)

DIWE - Fundamentals of PHP
DIWE - Fundamentals of PHPDIWE - Fundamentals of PHP
DIWE - Fundamentals of PHP
 
C++ oop
C++ oopC++ oop
C++ oop
 
Introduction to Client-Side Javascript
Introduction to Client-Side JavascriptIntroduction to Client-Side Javascript
Introduction to Client-Side Javascript
 
03 and 04 .Operators, Expressions, working with the console and conditional s...
03 and 04 .Operators, Expressions, working with the console and conditional s...03 and 04 .Operators, Expressions, working with the console and conditional s...
03 and 04 .Operators, Expressions, working with the console and conditional s...
 
Visula C# Programming Lecture 2
Visula C# Programming Lecture 2Visula C# Programming Lecture 2
Visula C# Programming Lecture 2
 
Basic c#
Basic c#Basic c#
Basic c#
 
Qcon2011 functions rockpresentation_f_sharp
Qcon2011 functions rockpresentation_f_sharpQcon2011 functions rockpresentation_f_sharp
Qcon2011 functions rockpresentation_f_sharp
 
Oops presentation
Oops presentationOops presentation
Oops presentation
 
JAVA Variables and Operators
JAVA Variables and OperatorsJAVA Variables and Operators
JAVA Variables and Operators
 
Python Programming
Python ProgrammingPython Programming
Python Programming
 
Oop2010 Scala Presentation Stal
Oop2010 Scala Presentation StalOop2010 Scala Presentation Stal
Oop2010 Scala Presentation Stal
 
JAVA OOP
JAVA OOPJAVA OOP
JAVA OOP
 
Visula C# Programming Lecture 7
Visula C# Programming Lecture 7Visula C# Programming Lecture 7
Visula C# Programming Lecture 7
 
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
 
Structured Languages
Structured LanguagesStructured Languages
Structured Languages
 
Perl slid
Perl slidPerl slid
Perl slid
 
Visual c sharp
Visual c sharpVisual c sharp
Visual c sharp
 
Type Classes in Scala and Haskell
Type Classes in Scala and HaskellType Classes in Scala and Haskell
Type Classes in Scala and Haskell
 
Domain Driven Design with the F# type System -- F#unctional Londoners 2014
Domain Driven Design with the F# type System -- F#unctional Londoners 2014Domain Driven Design with the F# type System -- F#unctional Londoners 2014
Domain Driven Design with the F# type System -- F#unctional Londoners 2014
 
Clean code slide
Clean code slideClean code slide
Clean code slide
 

Destacado

DISE - Introduction to Project Management
DISE - Introduction to Project ManagementDISE - Introduction to Project Management
DISE - Introduction to Project ManagementRasan Samarasinghe
 
Dot Net Framework An Overview
Dot Net Framework   An OverviewDot Net Framework   An Overview
Dot Net Framework An OverviewMicrosoftFeed
 
DITEC - Expose yourself to Internet & E-mail (second update)
DITEC - Expose yourself to Internet & E-mail (second update) DITEC - Expose yourself to Internet & E-mail (second update)
DITEC - Expose yourself to Internet & E-mail (second update) Rasan Samarasinghe
 
DITEC - Expose yourself to Internet & E-mail (updated)
DITEC - Expose yourself to Internet & E-mail (updated)DITEC - Expose yourself to Internet & E-mail (updated)
DITEC - Expose yourself to Internet & E-mail (updated)Rasan Samarasinghe
 
DITEC - Expose yourself to Internet & E-mail
DITEC - Expose yourself to Internet & E-mailDITEC - Expose yourself to Internet & E-mail
DITEC - Expose yourself to Internet & E-mailRasan Samarasinghe
 
DISE - Introduction to Software Engineering
DISE - Introduction to Software EngineeringDISE - Introduction to Software Engineering
DISE - Introduction to Software EngineeringRasan Samarasinghe
 
3장. Garbage Collection
3장. Garbage Collection3장. Garbage Collection
3장. Garbage Collection김 한도
 
DITEC - Fundamentals in Networking
DITEC - Fundamentals in NetworkingDITEC - Fundamentals in Networking
DITEC - Fundamentals in NetworkingRasan Samarasinghe
 
DISE - Software Testing and Quality Management
DISE - Software Testing and Quality ManagementDISE - Software Testing and Quality Management
DISE - Software Testing and Quality ManagementRasan Samarasinghe
 
DITEC - Fundamentals in Networking (updated)
DITEC - Fundamentals in Networking (updated)DITEC - Fundamentals in Networking (updated)
DITEC - Fundamentals in Networking (updated)Rasan Samarasinghe
 
DIWE - Introduction to Web Technologies
DIWE - Introduction to Web TechnologiesDIWE - Introduction to Web Technologies
DIWE - Introduction to Web TechnologiesRasan Samarasinghe
 
Slideshare Powerpoint presentation
Slideshare Powerpoint presentationSlideshare Powerpoint presentation
Slideshare Powerpoint presentationelliehood
 

Destacado (19)

DISE - Introduction to Project Management
DISE - Introduction to Project ManagementDISE - Introduction to Project Management
DISE - Introduction to Project Management
 
Dot Net Framework An Overview
Dot Net Framework   An OverviewDot Net Framework   An Overview
Dot Net Framework An Overview
 
DITEC - Expose yourself to Internet & E-mail (second update)
DITEC - Expose yourself to Internet & E-mail (second update) DITEC - Expose yourself to Internet & E-mail (second update)
DITEC - Expose yourself to Internet & E-mail (second update)
 
DITEC - Expose yourself to Internet & E-mail (updated)
DITEC - Expose yourself to Internet & E-mail (updated)DITEC - Expose yourself to Internet & E-mail (updated)
DITEC - Expose yourself to Internet & E-mail (updated)
 
DITEC - Expose yourself to Internet & E-mail
DITEC - Expose yourself to Internet & E-mailDITEC - Expose yourself to Internet & E-mail
DITEC - Expose yourself to Internet & E-mail
 
DITEC - Software Engineering
DITEC - Software EngineeringDITEC - Software Engineering
DITEC - Software Engineering
 
DISE - Introduction to Software Engineering
DISE - Introduction to Software EngineeringDISE - Introduction to Software Engineering
DISE - Introduction to Software Engineering
 
DISE - Programming Concepts
DISE - Programming ConceptsDISE - Programming Concepts
DISE - Programming Concepts
 
DITEC - E-Commerce & ASP.NET
DITEC - E-Commerce & ASP.NETDITEC - E-Commerce & ASP.NET
DITEC - E-Commerce & ASP.NET
 
DISE - OOAD Using UML
DISE - OOAD Using UMLDISE - OOAD Using UML
DISE - OOAD Using UML
 
DISE - Database Concepts
DISE - Database ConceptsDISE - Database Concepts
DISE - Database Concepts
 
3장. Garbage Collection
3장. Garbage Collection3장. Garbage Collection
3장. Garbage Collection
 
DITEC - Fundamentals in Networking
DITEC - Fundamentals in NetworkingDITEC - Fundamentals in Networking
DITEC - Fundamentals in Networking
 
DISE - Software Testing and Quality Management
DISE - Software Testing and Quality ManagementDISE - Software Testing and Quality Management
DISE - Software Testing and Quality Management
 
DITEC - Fundamentals in Networking (updated)
DITEC - Fundamentals in Networking (updated)DITEC - Fundamentals in Networking (updated)
DITEC - Fundamentals in Networking (updated)
 
DIWE - Introduction to Web Technologies
DIWE - Introduction to Web TechnologiesDIWE - Introduction to Web Technologies
DIWE - Introduction to Web Technologies
 
Programming with Python
Programming with PythonProgramming with Python
Programming with Python
 
Slideshare Powerpoint presentation
Slideshare Powerpoint presentationSlideshare Powerpoint presentation
Slideshare Powerpoint presentation
 
Slideshare ppt
Slideshare pptSlideshare ppt
Slideshare ppt
 

Similar a DITEC - Programming with C#.NET

CSharp Language Overview Part 1
CSharp Language Overview Part 1CSharp Language Overview Part 1
CSharp Language Overview Part 1Hossein Zahed
 
2.Getting Started with C#.Net-(C#)
2.Getting Started with C#.Net-(C#)2.Getting Started with C#.Net-(C#)
2.Getting Started with C#.Net-(C#)Shoaib Ghachi
 
2 programming with c# i
2 programming with c# i2 programming with c# i
2 programming with c# isiragezeynu
 
Csharp4 operators and_casts
Csharp4 operators and_castsCsharp4 operators and_casts
Csharp4 operators and_castsAbed Bukhari
 
Visual studio 2008
Visual studio 2008Visual studio 2008
Visual studio 2008Luis Enrique
 
CSharp Presentation
CSharp PresentationCSharp Presentation
CSharp PresentationVishwa Mohan
 
IntroToCSharpcode.ppt
IntroToCSharpcode.pptIntroToCSharpcode.ppt
IntroToCSharpcode.pptpsundarau
 
Functional programming with FSharp
Functional programming with FSharpFunctional programming with FSharp
Functional programming with FSharpDaniele Pozzobon
 
02. Primitive Data Types and Variables
02. Primitive Data Types and Variables02. Primitive Data Types and Variables
02. Primitive Data Types and VariablesIntro C# Book
 
02 Primitive data types and variables
02 Primitive data types and variables02 Primitive data types and variables
02 Primitive data types and variablesmaznabili
 
Complete Notes on Angular 2 and TypeScript
Complete Notes on Angular 2 and TypeScriptComplete Notes on Angular 2 and TypeScript
Complete Notes on Angular 2 and TypeScriptEPAM Systems
 
Introduction to-csharp
Introduction to-csharpIntroduction to-csharp
Introduction to-csharpSDFG5
 
Introduction to Csharp (C-Sharp) is a programming language developed by Micro...
Introduction to Csharp (C-Sharp) is a programming language developed by Micro...Introduction to Csharp (C-Sharp) is a programming language developed by Micro...
Introduction to Csharp (C-Sharp) is a programming language developed by Micro...NALESVPMEngg
 
Introduction-to-Csharp.ppt
Introduction-to-Csharp.pptIntroduction-to-Csharp.ppt
Introduction-to-Csharp.pptAlmamoon
 
Introduction-to-Csharp.ppt
Introduction-to-Csharp.pptIntroduction-to-Csharp.ppt
Introduction-to-Csharp.pptmothertheressa
 
IntroductionToCSharp.ppt
IntroductionToCSharp.pptIntroductionToCSharp.ppt
IntroductionToCSharp.pptRishikaRuhela
 

Similar a DITEC - Programming with C#.NET (20)

unit 1 (1).pptx
unit 1 (1).pptxunit 1 (1).pptx
unit 1 (1).pptx
 
C# - Part 1
C# - Part 1C# - Part 1
C# - Part 1
 
Notes(1).pptx
Notes(1).pptxNotes(1).pptx
Notes(1).pptx
 
CSharp Language Overview Part 1
CSharp Language Overview Part 1CSharp Language Overview Part 1
CSharp Language Overview Part 1
 
2.Getting Started with C#.Net-(C#)
2.Getting Started with C#.Net-(C#)2.Getting Started with C#.Net-(C#)
2.Getting Started with C#.Net-(C#)
 
2 programming with c# i
2 programming with c# i2 programming with c# i
2 programming with c# i
 
Csharp4 operators and_casts
Csharp4 operators and_castsCsharp4 operators and_casts
Csharp4 operators and_casts
 
Understanding linq
Understanding linqUnderstanding linq
Understanding linq
 
Visual studio 2008
Visual studio 2008Visual studio 2008
Visual studio 2008
 
CSharp Presentation
CSharp PresentationCSharp Presentation
CSharp Presentation
 
IntroToCSharpcode.ppt
IntroToCSharpcode.pptIntroToCSharpcode.ppt
IntroToCSharpcode.ppt
 
Functional programming with FSharp
Functional programming with FSharpFunctional programming with FSharp
Functional programming with FSharp
 
02. Primitive Data Types and Variables
02. Primitive Data Types and Variables02. Primitive Data Types and Variables
02. Primitive Data Types and Variables
 
02 Primitive data types and variables
02 Primitive data types and variables02 Primitive data types and variables
02 Primitive data types and variables
 
Complete Notes on Angular 2 and TypeScript
Complete Notes on Angular 2 and TypeScriptComplete Notes on Angular 2 and TypeScript
Complete Notes on Angular 2 and TypeScript
 
Introduction to-csharp
Introduction to-csharpIntroduction to-csharp
Introduction to-csharp
 
Introduction to Csharp (C-Sharp) is a programming language developed by Micro...
Introduction to Csharp (C-Sharp) is a programming language developed by Micro...Introduction to Csharp (C-Sharp) is a programming language developed by Micro...
Introduction to Csharp (C-Sharp) is a programming language developed by Micro...
 
Introduction-to-Csharp.ppt
Introduction-to-Csharp.pptIntroduction-to-Csharp.ppt
Introduction-to-Csharp.ppt
 
Introduction-to-Csharp.ppt
Introduction-to-Csharp.pptIntroduction-to-Csharp.ppt
Introduction-to-Csharp.ppt
 
IntroductionToCSharp.ppt
IntroductionToCSharp.pptIntroductionToCSharp.ppt
IntroductionToCSharp.ppt
 

Más de Rasan Samarasinghe

Managing the under performance in projects.pptx
Managing the under performance in projects.pptxManaging the under performance in projects.pptx
Managing the under performance in projects.pptxRasan Samarasinghe
 
Agile project management with scrum
Agile project management with scrumAgile project management with scrum
Agile project management with scrumRasan Samarasinghe
 
Application of Unified Modelling Language
Application of Unified Modelling LanguageApplication of Unified Modelling Language
Application of Unified Modelling LanguageRasan Samarasinghe
 
Advanced Web Development in PHP - Understanding REST API
Advanced Web Development in PHP - Understanding REST APIAdvanced Web Development in PHP - Understanding REST API
Advanced Web Development in PHP - Understanding REST APIRasan Samarasinghe
 
Advanced Web Development in PHP - Understanding Project Development Methodolo...
Advanced Web Development in PHP - Understanding Project Development Methodolo...Advanced Web Development in PHP - Understanding Project Development Methodolo...
Advanced Web Development in PHP - Understanding Project Development Methodolo...Rasan Samarasinghe
 
Advanced Web Development in PHP - Code Versioning and Branching with Git
Advanced Web Development in PHP - Code Versioning and Branching with GitAdvanced Web Development in PHP - Code Versioning and Branching with Git
Advanced Web Development in PHP - Code Versioning and Branching with GitRasan Samarasinghe
 
DIWE - Using Extensions and Image Manipulation
DIWE - Using Extensions and Image ManipulationDIWE - Using Extensions and Image Manipulation
DIWE - Using Extensions and Image ManipulationRasan Samarasinghe
 
DIWE - Programming with JavaScript
DIWE - Programming with JavaScriptDIWE - Programming with JavaScript
DIWE - Programming with JavaScriptRasan Samarasinghe
 
DIWE - Coding HTML for Basic Web Designing
DIWE - Coding HTML for Basic Web DesigningDIWE - Coding HTML for Basic Web Designing
DIWE - Coding HTML for Basic Web DesigningRasan Samarasinghe
 
DIWE - Multimedia Technologies
DIWE - Multimedia TechnologiesDIWE - Multimedia Technologies
DIWE - Multimedia TechnologiesRasan Samarasinghe
 

Más de Rasan Samarasinghe (13)

Managing the under performance in projects.pptx
Managing the under performance in projects.pptxManaging the under performance in projects.pptx
Managing the under performance in projects.pptx
 
Agile project management with scrum
Agile project management with scrumAgile project management with scrum
Agile project management with scrum
 
Introduction to Agile
Introduction to AgileIntroduction to Agile
Introduction to Agile
 
IT Introduction (en)
IT Introduction (en)IT Introduction (en)
IT Introduction (en)
 
Application of Unified Modelling Language
Application of Unified Modelling LanguageApplication of Unified Modelling Language
Application of Unified Modelling Language
 
Advanced Web Development in PHP - Understanding REST API
Advanced Web Development in PHP - Understanding REST APIAdvanced Web Development in PHP - Understanding REST API
Advanced Web Development in PHP - Understanding REST API
 
Advanced Web Development in PHP - Understanding Project Development Methodolo...
Advanced Web Development in PHP - Understanding Project Development Methodolo...Advanced Web Development in PHP - Understanding Project Development Methodolo...
Advanced Web Development in PHP - Understanding Project Development Methodolo...
 
Advanced Web Development in PHP - Code Versioning and Branching with Git
Advanced Web Development in PHP - Code Versioning and Branching with GitAdvanced Web Development in PHP - Code Versioning and Branching with Git
Advanced Web Development in PHP - Code Versioning and Branching with Git
 
DIWE - Using Extensions and Image Manipulation
DIWE - Using Extensions and Image ManipulationDIWE - Using Extensions and Image Manipulation
DIWE - Using Extensions and Image Manipulation
 
DIWE - File handling with PHP
DIWE - File handling with PHPDIWE - File handling with PHP
DIWE - File handling with PHP
 
DIWE - Programming with JavaScript
DIWE - Programming with JavaScriptDIWE - Programming with JavaScript
DIWE - Programming with JavaScript
 
DIWE - Coding HTML for Basic Web Designing
DIWE - Coding HTML for Basic Web DesigningDIWE - Coding HTML for Basic Web Designing
DIWE - Coding HTML for Basic Web Designing
 
DIWE - Multimedia Technologies
DIWE - Multimedia TechnologiesDIWE - Multimedia Technologies
DIWE - Multimedia Technologies
 

Último

Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonApplitools
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogueitservices996
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...Bert Jan Schrijver
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingShane Coughlan
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptxVinzoCenzo
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorTier1 app
 
Understanding Plagiarism: Causes, Consequences and Prevention.pptx
Understanding Plagiarism: Causes, Consequences and Prevention.pptxUnderstanding Plagiarism: Causes, Consequences and Prevention.pptx
Understanding Plagiarism: Causes, Consequences and Prevention.pptxSasikiranMarri
 
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...OnePlan Solutions
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLionel Briand
 
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdfSteve Caron
 
Advantages of Cargo Cloud Solutions.pptx
Advantages of Cargo Cloud Solutions.pptxAdvantages of Cargo Cloud Solutions.pptx
Advantages of Cargo Cloud Solutions.pptxRTS corp
 
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...kalichargn70th171
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsJean Silva
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics
 
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfPros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfkalichargn70th171
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfmaor17
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolsosttopstonverter
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxRTS corp
 
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jGraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jNeo4j
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...OnePlan Solutions
 

Último (20)

Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogue
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptx
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryError
 
Understanding Plagiarism: Causes, Consequences and Prevention.pptx
Understanding Plagiarism: Causes, Consequences and Prevention.pptxUnderstanding Plagiarism: Causes, Consequences and Prevention.pptx
Understanding Plagiarism: Causes, Consequences and Prevention.pptx
 
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and Repair
 
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
 
Advantages of Cargo Cloud Solutions.pptx
Advantages of Cargo Cloud Solutions.pptxAdvantages of Cargo Cloud Solutions.pptx
Advantages of Cargo Cloud Solutions.pptx
 
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero results
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
 
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfPros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdf
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration tools
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
 
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jGraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
 

DITEC - Programming with C#.NET

  • 1. Diploma in Information Technology Module IX: Programming with C#.NET Rasan Samarasinghe ESOFT Computer Studies (pvt) Ltd. No 68/1, Main Street, Pallegama, Embilipitiya.
  • 2. Contents 1. Introduction to .NET Framework 2. .NET Framework Platform Architecture 3. Microsoft Visual Studio 4. C# Language 5. C#, VS and .NET Framework Versions 6. Your First C# Application 7. Printing Statements 8. Comments in C# 9. Common Type System 10. Value Types and Reference Type 11. Variables Declaration in C# 12. Type Conversion 13. Arithmetic Operators 14. Assignment Operators 15. Comparison Operators 16. Logical Operators 17. If Statement 18. If… Else Statement 19. If… Else if… Else Statement 20. Nested If Statement 21. Switch Statement 22. While Loop 23. Do While Loop 23. For Loop 24. Arrays 25. Accessing Arrays using foreach Loop 26. Two Dimensional Arrays 27. Classes and Objects in C# 28. Inheritance in C# 29. Partial Classes 30. Namespaces 31. Windows Forms Applications 32. Using Buttons, Labels and Text Boxes 33. Displaying Message Boxes 34. Error Handling with Try… Catch… finally… 35. Using Radio Buttons 36. Using Check Boxes 37. Using List Boxes 38. Creating Menus 39. Creating ToolStrips 40. MDI Forms 41. Database Application in C# 42. Creating a Simple Database Application 43. SQL Insert / Update / Retrieving / Delete 44. SQL Command Execute Methods 45. Data Sets
  • 3. Introduction to .NET Framework • The .NET Framework is a software framework developed by Microsoft that runs primarily on Microsoft Windows. • It includes a large library and provides language interoperability across several programming languages. • Programs written for .NET Framework execute in a software environment known as CLR. • .NET Framework is intended to be used by most new applications created for the Windows platform.
  • 4. .NET Framework Platform Architecture
  • 5. Microsoft Visual Studio • Microsoft Visual Studio is an integrated development environment (IDE) from Microsoft… • To develop Windows Forms or WPF applications, web sites, web applications, and web services… • For Microsoft Windows, Windows Mobile, Windows CE, .NET Framework and Microsoft Silverlight.
  • 6. C# Language C# is a general purpose, object oriented programming language developed by Microsoft within its .NET initiative led by Anders Hejlsberg.
  • 7. C# Language Features • Boolean Conditions • Automatic Garbage Collection • Standard Library • Assembly Versioning • Properties and Events • Delegates and Events Management • Easy-to-use Generics • Indexers • Conditional Compilation • Simple Multithreading • LINQ and Lambda Expressions • Integration with Windows
  • 8. C#, VS and .NET Framework Versions C# Version Visual Studio Version .NET Framework Version C# 1.0 Visual Studio .NET 2002 .NET Framework 1.0 C# 1.2 Visual Studio .NET 2003 .NET Framework 1.1 C# 2.0 Visual Studio 2005 .NET Framework 2.0 C# 3.0 Visual Studio 2008 Visual Studio 2010 .NET Framework 2.0 .NET Framework 3.0 .NET Framework 3.5 C# 4.0 Visual Studio 2010 .NET Framework 4 C# 5.0 Visual Studio 2012 Visual Studio 2013 .NET Framework 4.5
  • 9. Your First C# Application using System; namespace myspace { class FirstApp { static void Main() { Console.WriteLine(“Hello World!”); } } }
  • 10. Printing Statements Console.Write(“Hello World!”); //prints a text Console.WriteLine(“Hello World!”); //prints text and starts a new line Console.Write(“Hello nWorld!”); //line breaks Console.Write(“Hello {0}”, “Esoft”); //variable displaying
  • 11. Comments in C# Single line comments // this is a single line comment Multiline comments /* this is a multiline comment */
  • 13. Value Types and Reference Type Predefined Value Types sbyte -128 to 127 8 bits byte 0 to 255 8 bits short -32,768 to 32,767 16 bits ushort 0 to 65,535 16 bits int -2,147,483,648 to 2,147,483,647 32 bits uint 0 to 4,294,967,295 32 bits long -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 64 bits ulong 0 to 18,446,744,073,709,551,615 64 bits char 16 bit Unicode character 16 bits float -3.4 x 1038 to + 3.4 x 1038 32 bits double (+/-)5.0 x 10-324 to (+/-) 1.7 x 10308 64 bits decimal (-7.9 x 1028 to 7.9 x 1028) / 100 to 28 128 bits bool Holds true or false 1 bit Predefined Reference Types string Represents a string of Unicode characters 20+ bits object Represents a general purpose type 8+ bits
  • 14. Variable Declaration in C# Variable declaration type variable_list; Variable declaration and initialization type variable_name = value;
  • 15. Variable Declaration in C# int a, b, c; // declares three ints, a, b, and c. int d = 3, e, f = 5; // declares three more ints, initializing d and f. bool z = 5>2; // declares and initializes z. double pi = 3.14159; // declares an approximation of pi. char x = 'x'; // the variable x has the value 'x'.
  • 16. Type Conversion • Implicit Conversion – No special syntax is required because the conversion is type safe and no data will be lost. • Explicit Conversion – Require a cast operator, and information might be lost in the conversion. • Conversions with helper classes – To convert between non-compatible types.
  • 17. Implicit Conversion int x = 123; double y = x;
  • 18. Explicit Conversion double y = 123.5; int x = (int)y;
  • 19. Conversions with helper classes String x = "123"; int y = Int.Parse(x); int z = Convert.ToInt32(x);
  • 20. Arithmetic Operators Operator Description Example + Addition X + Y will give 60 - Subtraction X - Y will give -20 * Multiplication X * Y will give 800 / Division Y / X will give 2 % Modulus Y % X will give 0 ++ Increment Y++ gives 41 -- Decrement Y-- gives 39 X = 20, Y = 40
  • 21. Assignment Operators Operator Example = Z = X + Y will assign value of X + Y into Z += Z += X is equivalent to Z = Z + X -= Z -= X is equivalent to Z = Z - X *= Z *= X is equivalent to Z = Z * X /= Z /= X is equivalent to Z = Z / X %= Z %= X is equivalent to Z = Z % X
  • 22. Comparison Operators Operator Example == (X == Y) is false. != (X != Y) is true. > (X > Y) is false. < (X < Y) is true. >= (X >= Y) is false. <= (X <= Y) is true. X = 50, Y = 70
  • 23. Logical Operators Operator Name Example && AND (X && Y) is False || OR (X || Y) is True ! NOT !(X && Y) is True X = True, Y = False
  • 24. If Statement if(Boolean_expression) { // Statements will execute if the Boolean expression is true } Boolean Expression Statements True False
  • 25. If… Else Statement if(Boolean_expression) { // Executes when the Boolean expression is true } else { // Executes when the Boolean expression is false } Boolean Expression Statements True False Statements
  • 26. If… Else if… Else Statement if(Boolean_expression 1) { // Executes when the Boolean expression 1 is true } else if(Boolean_expression 2) { // Executes when the Boolean expression 2 is true } else if(Boolean_expression 3) { // Executes when the Boolean expression 3 is true } else { // Executes when the none of the above condition is true. }
  • 27. If… Else if… Else Statement Boolean expression 1 False Statements Boolean expression 2 Boolean expression 3 Statements Statements False False Statements True True True
  • 28. Nested If Statement if(Boolean_expression 1) { // Executes when the Boolean expression 1 is true if(Boolean_expression 2) { // Executes when the Boolean expression 2 is true } } Boolean Expression 1 True False Statements Boolean Expression 2 True False
  • 29. Switch Statement switch (value) { case constant: // statements break; case constant: // statements break; default: // statements break; }
  • 31. Do While Loop do { // Statements }while(Boolean_expression); Boolean Expression Statements True False
  • 32. For Loop for(initialization; Boolean_expression; update) { // Statements } Boolean Expression Statements True False Update Initialization
  • 33. Arrays 10 30 20 50 15 35 0 1 2 3 4 5 Size = 6 Element Index No An Array can hold many values in a same data type under a single name A single dimensional array
  • 34. Building a Single Dimensional Array // creating an Array DataType[] ArrayName = new DataType[size]; // assigning values ArrayName[index] = value; ArrayName[index] = value; ……..
  • 35. Building a Single Dimensional Array char[] letters = new char[4]; letters[0] = ‘O’; letters[1] = ‘P’; letters[2] = ‘Q’; letters[3] = ‘R’; 0 1 2 3 O P Q R 0 1 2 3 letters letters Values in an Array can access by referring index number
  • 36. Building a Single Dimensional Array // creating an array using array initializer DataType[] ArrayName = {element 1, element 2, element 3, … element n}; int[] marks = {10, 20, 30, 40, 50}; 10 20 30 40 0 1 2 3 intArr 50 4
  • 37. Accessing Arrays using foreach Loop // creating an Array int[] marks = {10, 29, 30, 40, 50, 70}; // accessing array elements foreach(int n in marks) { System.Console.WriteLine(n); }
  • 38. Two Dimensional Arrays 5 10 15 25 50 75 0 1 2 0 1 int[,] myMatrix = new int[2,3]; myMatrix[0,0] = 5; myMatrix[0,1] = 10; myMatrix[0,2] = 15; myMatrix[1,0] = 25; myMatrix[1,1] = 50; myMatrix[1,2] = 75; Rows Columns Column Index Row Index
  • 39. Two Dimensional Arrays Using array initializer… int[,] myMatrix = new int[2,3] {{5,10,15},{25,50,75}}; int[,] myMatrix = {{5,10,15},{25,50,75}}; Or
  • 40. Classes and Objects in C# Method Student name age Register() class Student { public String name; public int age; public Student(){ } public void Register(){ Console.WriteLine(“Registered!”); } } Attributes Constructor
  • 41. C# Objects Student st = new Student(); //creating an object //Assigning values to Attributes st.name = “Roshan”; st.age = 20; //calling method st.Register();
  • 42. Inheritance in C# class Animal { //attributes and methods } class Lion : Animal { //attributes and methods } class Cat : Animal { //attributes and methods } Animal Lion Cat
  • 43. Partial Classes partial class Student { public int age; } partial class Student { public String name; } partial class Student { public String address; public void Register(){ Console.Write("Student Registered"); } } Partials of the same class
  • 44. Namespaces • Namespace is an organization construct. • It’s a group of collected types. • It’s helping to understand how the code base is arranged. • Namespaces are not essential for C# programs. namespace esoft { class ditec{ } class dise{ } }
  • 45. Importing Namespaces Importing Namespace by using “using” directive using System.Linq; Importing Namespace with alias directive using ns = System.Linq; Direct accessing Namespaces System.Console.WriteLine(“hello”);
  • 46. Windows Forms Applications • A Windows Forms application is an event- driven application supported by Microsoft's .NET Framework. • This model provides object-oriented, extensible set of classes that enable you to develop rich Windows applications.
  • 47. Using Button, Labels and Text Boxes private void button1_Click(object sender, EventArgs e) { label2.Text = "Welcome " + textBox1.Text; }
  • 48. Displaying Message Boxes MessageBox.Show("Hello World","MessageBox Demo",MessageBoxButtons.YesNo, MessageBoxIcon.Information); MessageBox.Show("Hello World“);
  • 49. Error Handling with Try… Catch… finally… try { //Protected code } catch (Exception ex) { //Catch block } finally { //The finally block always executes }
  • 50. Using Radio Buttons private void button1_Click(object sender, EventArgs e) { if (radioButton1.Checked) { MessageBox.Show("You have chosen Black"); } else { MessageBox.Show("You have chosen White"); } }
  • 51. Using Check Boxes private void button1_Click(object sender, EventArgs e) { if (checkBox1.Checked) { MessageBox.Show("You have accepted Terms of Agreement"); } else { MessageBox.Show("You haven't accepted Terms of Agreement"); } }
  • 52. Using List Boxes Statements for each button click events listBox1.Items.Add(textBox1.Text); listBox1.Items.AddRange(new String[] { “America", “Japan", “India" }); listBox1.Items.Insert(0, textBox1.Text); listBox1.Items.Remove(listBox1.SelectedItem); listBox1.Items.RemoveAt(int.Parse(textBox1.Text )); listBox1.Items.Clear(); listBox1.Sorted = true;
  • 53. Creating Menus private void newToolStripMenuItem_Click(object sender, EventArgs e) { MessageBox.Show("You have clicked New Menu item!"); }
  • 54. Creating ToolStrips private void newToolStripButton_Click(object sender, EventArgs e) { MessageBox.Show("You have clicked newToolStripButton!"); }
  • 55. MDI Forms private void document1ToolStripMenuItem_Click(object sender, EventArgs e) { Document_One form1 = new Document_One(); form1.MdiParent = this; form1.Show(); }
  • 56. Database Application in C# Application DataBase Insert, Update, Retrieving and Delete Processes
  • 57. Creating a Simple Database Application Creating a simple database application involved with following steps. 1. Import the namespaces 2. Creating a SQL Connection 3. Open SQL Connection 4. Create a SQL Command 5. Execute the SQL Command 6. Extract data from SQL Data Reader 7. Clean up the environment
  • 58. Creating a Simple Database Application using System; using System.Data.SqlClient; class Program { static void Main(string[] args) { SqlConnection con = new SqlConnection("Data Source=.SQLEXPRESS; Initial Catalog=esoftdb; Integrated Security=yes"); con.Open(); SqlCommand cmd = new SqlCommand("SELECT * FROM tblStudent", con); SqlDataReader rd = cmd.ExecuteReader(); while (rd.Read()) { Console.Write(rd["id"].ToString() + " "); Console.Write(rd["name"].ToString() + " "); Console.WriteLine(rd["address"].ToString()); } rd.Close(); con.Close(); Console.ReadLine(); } } 1 2 3 4 5 6 7
  • 59. SQL Insert / Update / Retrieving / Delete Inserting Data into Database SqlCommand cmd = new SqlCommand(“INSERT tblStudent VALUES(1, ‘Roshan’, ‘Colombo’)", con); Updating Data in Database SqlCommand cmd = new SqlCommand(“UPDATE tblStudent SET address=‘kandy’ WHERE id=1", con); Retrieving Data from Database SqlCommand cmd = new SqlCommand("SELECT * FROM tblStudent", con); Deleting Data in Database SqlCommand cmd = new SqlCommand(“DELETE FROM tblStudent WHERE id=1", con);
  • 60. SQL Command Execute Methods • ExecuteNonQuery() : Executes a Transact-SQL statement against the connection and returns the number of rows affected. • ExecuteReader() : Sends the CommandText to the Connection and builds a SqlDataReader. • ExecuteScalar() : Executes the query, and returns the first column of the first row in the result set returned by the query. int n = cmd.ExecuteNonQuery(); SqlDataReader rd = cmd.ExecuteReader(); String name= cmd.ExecuteScalar();
  • 61. Data Sets Represents an in-memory cache of data. SqlConnection con = new SqlConnection("Data Source=.SQLEXPRESS; Initial Catalog=esoftdb; Integrated Security=yes"); SqlCommand cmd = new SqlCommand("SELECT * FROM tblStudent", con); SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds, “tblStudent”);