W01 Introduction
W01 Introduction
• Programming Paradigms
• Dot Net Framework Architecture
• C# Compilation and Execution
• Structure of a C# Program
• Console and Windows Applications
Outline
Programming Paradigms
• Structured Programming
• Visual Programming
Structured Programming
Structured Programming
Structured Programming
Object-oriented Programming
Object-oriented Programming
Visual Programming
Visual Computing
Visual
Programming
Computer
Graphics
Algorithm
Animation
Scientific
User Interfaces Visualization
Related Areas
.NET Framework
.NET Framework
.NET Architecture
.NET Framework
C# source
code
MSIL
C#
compiler
CLR
Machine
code
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 codes from different languages can be
linked together to form a program
Interoperability
Visual
C# VB .NET
J# .NET
Compile
into MSIL
CLR generate
single application
(native code)
Windows
Native Code
FCL
C# Program Structure
A Simple C# Program
using System;
class HelloWorld
{
static void Main(string[] args)
{
Console.WriteLine(“Hello, World!”);
}
}
Namespace
using System;
class HelloWorld
class HelloWorld {
{ static void Main(string[] args)
static void Main(string[] args) {
{ System.Console.WriteLine(“Hello”);
Console.WriteLine(“Hello”); }
} }
}
Comments
Identifiers
Keywords
C# Keywords
C# Keywords
abstract as base bool break
byte case catch char checked
class const continue decimal default
delegate do double else enum
event explicit extern false finally
fixed float for foreach get
goto if implicit in int
interface internal is lock long
namespace new null object operator
out override params private protected
public readonly ref return sbyte
sealed set short sizeof stackalloc
static string struct switch this
throw true try typeof uint
ulong unchecked unsafe ushort using
value virtual void volatile while
C# Class Structure
class body
C# Class Structure
C# Methods
All
programs start by executing the Main
method
• Console Application
– No visual component
– Only text input and output
– Run under Command Prompt or DOS Prompt
• Window Application
– Forms with many different visual components
– Contains Graphical User Interfaces (GUI)
– GUI is more user friendly!
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);
}
}
C# Windows Application
using System;
using System.Windows.Forms;
class Welcome
{
static void Main( string[] args )
{
MessageBox.Show("Welcome\n to\n C#\n programming!");
}
}