0% found this document useful (0 votes)
25 views

Lecture 03-04 (C# Env and Overview)

Uploaded by

Javeria Anwer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

Lecture 03-04 (C# Env and Overview)

Uploaded by

Javeria Anwer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 36

CS-404 Visual Programming

Lecture 03 (The C# Environment)


Course Teacher: Awais Mehmood, Department of Computer Science, UET, Taxila (Pakistan)
DEPARTMENT OF COMPUTER SCIENCE, UET TAXILA (PAKISTAN) 1
Understanding .NET
Goals for today

The C# Environment

DEPARTMENT OF COMPUTER SCIENCE, UET TAXILA (PAKISTAN) 2


The.NET Strategy
▪ .NET is a software framework that includes everything required for
developing software services for desktop and the Web.
▪ It integrates presentation technologies, component technologies &
data technologies on a single platform so as to enable users to
develop Internet applications.
▪ Components (next slide)

DEPARTMENT OF COMPUTER SCIENCE, UET TAXILA (PAKISTAN) 3


The.NET Strategy (components)
▪ MS Intermediate Language
▪ Code is complied into a more abstract, trimmed version before execution.
▪ All .NET languages are compiled to MSIL – the common language of .NET
▪ The CLR- common language runtime:
▪ Responsible for executing MSIL code; interfaces to Windows and IIS
▪ A rich set of libraries (Framework Class Libraries)
▪ Available to all .NET languages
▪ The .NET languages
▪ such as C#, VB.NET, J#, F# etc. that conform to CLR

DEPARTMENT OF COMPUTER SCIENCE, UET TAXILA (PAKISTAN) 4


The Origins of .NET Technology
▪ The current technology of .NET has gone through three different
phases of development:
▪ OLE technology
▪ COM technology
▪ .NET technology

DEPARTMENT OF COMPUTER SCIENCE, UET TAXILA (PAKISTAN) 5


OLE Technology
▪ Developed by Microsoft to enable easy inter-process communications.
▪ OLE provides support to achieve following:
▪To embed documents from one application into another application
▪To enable one application to manipulate objects located in another
application

DEPARTMENT OF COMPUTER SCIENCE, UET TAXILA (PAKISTAN) 6


COM Technology
▪ Overcomes the problems of maintaining and testing of software.
▪ A program can be divided into number of independent components
where each one offers a particular service.
▪ Each component can be developed & tested independently and then
integrated into the main system.
▪ The software built using COM is referred to as componentware.
▪ Benefits:
▪ Reduces Complexity * Enhances software maintainability, and Enables
distributed development across multiple organizations

DEPARTMENT OF COMPUTER SCIENCE, UET TAXILA (PAKISTAN) 7


The Origins of .NET Technology
▪ .NET Technology is third generation component model
▪ Provides a new level of inter-operability compared to COM technology
▪ Inter-module communication is achieved using Microsoft Intermediate
Language (MSIL) or simply IL
▪ allows for true cross language integration
▪ provides metadata: characteristic of data including datatypes & locations.

DEPARTMENT OF COMPUTER SCIENCE, UET TAXILA (PAKISTAN) 8


The Origins of .NET Technology (cont…)

DEPARTMENT OF COMPUTER SCIENCE, UET TAXILA (PAKISTAN) 9


The .NET
Framework

DEPARTMENT OF COMPUTER SCIENCE, UET TAXILA (PAKISTAN) 10


.NET Framework (contd.)
▪ One of the tools provided by the .NET infrastructure & tools component of
the .NET platform.
▪ Provides an environment for building, deploying & running web services &
other applications.
▪ Consists of three distinct technologies:
▪Common Language Runtime
▪Framework Base Classes
▪User & program interfaces (ASP .NET)

DEPARTMENT OF COMPUTER SCIENCE, UET TAXILA (PAKISTAN) 11


Common Language Runtime (CLR)
▪ The heart & soul of the .NET framework
▪ Responsible for loading & running C# programs.
▪ Supports cross-language interoperability.
▪ Services provided:
▪ Loading & execution of programs, Verification of type-safety, Providing
metadata, Memory management, Enforcement of security, Interoperability
with other systems, Managing exceptions & errors, and Debugging

DEPARTMENT OF COMPUTER SCIENCE, UET TAXILA (PAKISTAN) 12


Components of CLR

13
Framework Base Classes
▪ Allows to implement applications quickly
▪ The functionality of the base framework classes resides in the namespace
called System
▪ Provides:
▪ Input/Output operations • String handling • Managing arrays, lists, maps, etc. •
Accessing to files & file system • Accessing to the registry • Security • Windowing
• Database management • Drawing • Error & exception Management and •
Connecting to Internet

DEPARTMENT OF COMPUTER SCIENCE, UET TAXILA (PAKISTAN) 14


User and Program Interfaces
▪ The .NET framework provides the following tools for managing user
& application interfaces:
▪ Windows forms
▪ Web forms
▪ Console applications
▪ Web Services

▪ These tools enable users to develop user-friendly desktop-based as


well as web-based applications.

DEPARTMENT OF COMPUTER SCIENCE, UET TAXILA (PAKISTAN) 15


16
Benefits of .NET Approach
▪ Some of the many benefits are: ▪ Wide range of scalability
▪ Simpler & faster systems development ▪ Interoperability with existing
▪ Enhanced built-in functionality applications
▪ Several ways to communicate with the ▪ Fewer bugs
outside world ▪ Potentially better performance
▪ Integration of different languages into
one platform
▪ Easy execution

DEPARTMENT OF COMPUTER SCIENCE, UET TAXILA (PAKISTAN) 17


Questions?
CS-404 Visual Programming
Lecture 04 (Overview of C#.NET)
Course Teacher: Awais Mehmood, Department of Computer Science, UET, Taxila (Pakistan)
DEPARTMENT OF COMPUTER SCIENCE, UET TAXILA (PAKISTAN) 19
▪ Overview of C#
Goals for ▪ Simple C# Program

today ▪ Interacting with C# Programs

DEPARTMENT OF COMPUTER SCIENCE, UET TAXILA (PAKISTAN) 20


Introduction

21
DEPARTMENT OF COMPUTER SCIENCE, UET TAXILA (PAKISTAN)
A simple C#
program

DEPARTMENT OF COMPUTER SCIENCE, UET TAXILA (PAKISTAN) 22


Namespaces
▪ The base class libraries are organized into logical groupings of code
called namespaces
▪ A hierarchical way to identify resources in .NET
▪ The System object is at the top of the namespace hierarchy, and all
objects inherit from it
▪ ASP.NET: System.Web namespace
▪ WebForms: System.Web.UI namespace
▪ HTML Server Controls: System.Web.UI.Control.HTMLControl
▪ ASP.NET Server Controls: System.Web.UI.Control.WebControl

DEPARTMENT OF COMPUTER SCIENCE, UET TAXILA


Namespaces

24
.NET Framework – Architecture
System.Web System.WinForms
Web Services Web Forms Controls Drawing

ASP.NET Application Services Windows Application Services

System Base Framework


ADO.NET XML SQL Threading

IO Net Security ServiceProcess

Common Language Runtime


Type System Metadata Execution

DEPARTMENT OF COMPUTER SCIENCE, UET TAXILA


Adding
Comments

DEPARTMENT OF COMPUTER SCIENCE, UET TAXILA (PAKISTAN) 26


Main() returning a value
▪ The main() can return a value if it is declared as
int instead of void.
▪ When the return type is int, we must include a
return statement at the end of the method.
▪ The value returned serves as the program’s
termination status code.
▪ It allows the communication of success or failure
to the execution environment.

DEPARTMENT OF COMPUTER SCIENCE, UET TAXILA (PAKISTAN) 27


Using Aliases
for NAMESPACE
classes

DEPARTMENT OF COMPUTER SCIENCE, UET TAXILA (PAKISTAN) 28


Passing String Objects to WriteLine Method
using System;
class SampleFive
{
public static void Main()
{
string name=“UET Taxila”;
Console.WriteLine(name);
}
}
DEPARTMENT OF COMPUTER SCIENCE, UET TAXILA (PAKISTAN) 29
MAIN with a
class

DEPARTMENT OF COMPUTER SCIENCE, UET TAXILA (PAKISTAN) 30


Providing
Interactive
input

DEPARTMENT OF COMPUTER SCIENCE, UET TAXILA (PAKISTAN) 31


using System;
class SampleNine
{
Using public static void Main(string[] args)
mathematical {
double x=5.0;
functions double y;
y=Math.Sqrt(x);
Console.WriteLine(“y = ”+y);
}
}

DEPARTMENT OF COMPUTER SCIENCE, UET TAXILA (PAKISTAN) 32


Multiple Main() methods

DEPARTMENT OF COMPUTER SCIENCE, UET TAXILA (PAKISTAN) 33


Compile time errors

34
Program structure

35
Thank you
Ethics is knowing the difference between what you have a right to
do and what is right to do.
- Potter Stewart
DEPARTMENT OF COMPUTER SCIENCE, UET TAXILA (PAKISTAN) 36

You might also like