Professional Documents
Culture Documents
.NET Framework
Page 3
Page 4
.NET Framework
❑ MicroSoft Intermediate Language (MSIL)
Page 5
C# source
code
MSIL
C#
compiler
CLR
Machine
code
Page 6
MSIL Advantages
o Portability between OS
➢ .NET compliant languages are all compiled into
MSIL (portable between OS)
o Language Interoperability
➢ Different languages can communicate easily
➢ MSIL code from different languages can be
linked together to form a program
Page 7
Page 8
C# Data Types
Page 9
Page 10
Page 11
Page 12
A Simple C# Program
using System;
class HelloWorld
{
static void Main(string[] args)
{
Console.WriteLine(“Hello, World!”);
}
}
Page 13
Page 14
C# Console Application
using System;
class Hello
{
static void Main(string[] args)
{
Console.Write(“Your Name Please: “);
string name = Console.ReadLine();
Console.WriteLine(“Hello “ + name);
}
}
Page 15
Page 16
// initialization phase
total = 0; // clear total
gradeCounter = 1; // prepare to loop
// processing phase
while ( gradeCounter <= 10 ) // loop 10 times
{
// prompt for input and read grade from user
Console.Write( "Enter integer grade: " );
// add 1 to gradeCounter
gradeCounter = gradeCounter + 1;
}
Page 17
Class average is 79
Page 18
Page 19
System.Array
Page 20
Array: Length
Each array has a public property called Length that stores the
size of the array
◦ once an array is created, it has a fixed size
Page 21
Page 22
Page 23
24
Page 24
Jagged Arrays
A Jagged array is often called an array of arrays.
An element of a jagged array itself is an array.
25
Page 25
jA jA[0]
jA[1]
jA[2]
jA[3]
jA[4]
jA[5]
Page 26
Page 27
class Drawing
{
private string color;
public string Color
{ get { return color; }
set { color = value; }
}
……
}
Page 28
28
Properties
Only one method is required - either get or set, the other is
optional. This allows you to define:
◦ read-only and write-only properties.
Page 29
29
set
{
if ( (value > 0) && (value < 13) )
{
month = value;
}
}
}
}
Page 30
Page 31