Advanced Programming
Introduction .Net
1
Dr. Farman Ullah (CUI Abbottabad)
Topics
1. C# vs .NET
2. Common Language Runtime (CLR)
3. Architecture of .NET Applications
4. Native AOT (Ahead-of-Time Compilation)
5. Our First C# Application
Introduction to Visual Programming
Visual Programming ?
Visual programming is a programming paradigm where developers create
applications by interacting with graphical elements instead of writing code
manually.
It uses visual components such as:
▪ Icons
▪ Forms
▪ Drag-and-drop controls
Key Points:
Easier for beginners
Reduces syntax errors
Still requires coding in most real-world applications
Examples: Visual Basic, Visual C#, Visual C++s
Programming Approaches
1. Console Programming
Text-based interaction (CLI)
2. GUI Programming
Code-based graphical interface development
3. Visual Programming
Drag-and-drop UI design with minimal coding
Console Application
Applications that interact with users through a Command-Line Interface (CLI).
Features:
Input and output are text-based
Lightweight and fast
Requires minimal system resources
Common Uses:
System utilities
Automation scripts
Backend services
GUI Approaches
GUI programming involves writing code to create and manage
interfaces such as buttons, forms, and menus.
Features:
Requires coding to design UI and handle events
Provides full control and customization
Used in modern desktop and web applications
Examples:
C# (Windows Forms, WPF)
Java (Swing, JavaFX)
Python (Tkinter, PyQt)
graphical
GUI Approaches
using
using
using
System;
System.Windows.Forms
;
static
System.Net.Mime.
MediaTypeNames ;
public
class
MyForm : Form
{
public
MyForm()
{
Button btn = new Button();
btn .Text = "Click Me"
;
btn .Click
+= ( s , e) => MessageBox.Show
Controls.Add
( btn );
}
public
static
{
Application
}
}
void
Main ()
.Run ( new MyForm());
( "Button Clicked"
);
Programming Approaches
Visual programming allows developers to design applications using drag-anddrop components instead of writing UI code manually.
Features:
Uses pre-built controls (buttons, forms, menus)
Faster UI development
Low-code / No-code approach
Example:
In Visual Studio, you can drag a button onto a form and set its properties
without writing code.
C# vs .Net (Dotnet)
C#
▪ A modern, object-oriented programming language
▪ Used to write application logic
▪ Syntax similar to Java/C++
.NET
▪ A development framework/platform
▪ Provides runtime, libraries, and tools
▪ Supports multiple languages (C#, F#, VB.NET)
C# runs on .NET
.Net Evolution
1. .NET Framework (2002 – 2022)
• Windows-only
• Latest: 4.8.1
2. .NET Core (2016 – 2020)
• Cross-platform
• High performance
3. Modern .NET (5+)
• Unified platform
• Cross-platform (Windows, Linux, macOS)
• Latest: .NET 9
.Net Timeline
▪ 2002 → .NET Framework
▪ 2016 → .NET Core
▪ 2020 → .NET 5 (Unified Platform)
Today:
• .NET is cross-platform
• Supports desktop, web, mobile, and cloud apps
.NET Architecture Overview
Layers:
Application Layer (ASP.NET, WinForms)
Framework Class Library (FCL)
Common Language Runtime (CLR)
CLR Handles:
Memory management
Execution
Security
.NET Architecture Overview
.Net (Framework)
A software framework developed by Microsoft
Used to build desktop, web, and enterprise applications
Provides a rich Base Class Library (BCL)
Features:
GUI development
Database connectivity
Web services support
Common Language Runtime (CLR)
The execution engine of .NET
Runs .NET applications
Responsibilities:
Memory management (Garbage Collection)
Security
Exception handling
Code execution
Note:
➢ C# code is compiled into Intermediate Language (IL), which is
executed by the CLR.
Native AOT (Ahead-of-Time Compilation)
Compiles .NET applications into native machine code before execution
Advantages:
Faster startup time
Lower memory usage
No JIT compilation required
Use Cases:
High-performance applications
Microservices
Resource-constrained systems
Supported in:
.NET 7 and later
Q&A
Does .NET use a single compiler?
No -> .NET does NOT use a single compiler
Instead:
Each language has its own compiler
But all compilers generate the same Intermediate Language (IL)
Examples:
C# → Roslyn Compiler (csc.exe)
VB.NET → vbc.exe
F# → fsc.exe
Thank You
Dr. Farman Ullah (CUI Abbottabad)