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

Course 1 - NET Internals

The document provides an introduction to C#, the .NET framework, and Visual Studio 2008. It discusses the key features of C# and how it was designed for the .NET platform. It also describes the main components of the .NET framework including the common language runtime, common type system, and common language specification.

Uploaded by

alecsander_008
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
351 views

Course 1 - NET Internals

The document provides an introduction to C#, the .NET framework, and Visual Studio 2008. It discusses the key features of C# and how it was designed for the .NET platform. It also describes the main components of the .NET framework including the common language runtime, common type system, and common language specification.

Uploaded by

alecsander_008
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

.

NET Summer Rally 2009

Introduction to C# and the


Object Oriented Programming
Firstly: about us and about you
• Instructors:
– Timotei Dolean
– Octavian Hasna
– Mihai Cornean
– Vlad Precup
About the course
• Intensive study:
– 4-5 hours/day -> lectures and practical work
– 1-3 hours/day -> individual study
• 5 days:
– Today: Introduction to C#, .NET Fw., VS 2008, OOP
– Tuesday: OOP in-depth, inheritance and polymorphism
– Wednesday: Value/reference types, working w/ interfaces
– Thursday: C# constructs, more on Win. Forms
– Friday: Exception handling, collections, generics
Course 1

Introduction to C#, .NET Framework


and Visual Studio 2008

Lecturer: Vlad Precup


vlad.precup@student-partners.com
Contents
• C#
• .NET Framework and its building blocks
• .NET Assemblies
• Common Intermediate Language
• Data Types supported by .NET
• .NET Platform independence
C#
• Appeared in 2000, high-level language
• Syntax – based on C++
• Has roots in C, C++, Delphi and Java => a product
that is as syntactically clean—if not cleaner—
than Java, is about as simple as VB6, and provides
just about as much power and flexibility as C++.
• Designed specifically for the .NET Platform
• Object-oriented
C# - Core Features
• No pointers required
• Automatic memory management (GC)
• Formal syntactic constructs for different data
types
• The ability to overload operators
• Support for attribute-based programming
Before the .NET
• C/Win32 API
• C++/MFC
• Visual Basic 6.0
• Java/J2EE
• COM
• Windows DNA
And there was the .NET initiative
• A new vision for embracing the Internet and
the Web in the development and use of
software
• The solution proposed by .NET is “Change
everything”.
• Programming-language independent
(developers can create a .NET application in
any .NET-compatible language)
The .NET Framework
• A completely new model for building systems
on the Windows family of operating systems,
as well as on
– Mac OS X
– Unix/Linux.
• Web-based applications can be distributed to
a great variety of devices (even cell phones)
and to desktop computers.
The .NET Framework
Features:
• manages and executes applications and Web
services
• contains a comprehensive class library (FCL)
• enforces security
The .NET Framework
• Provides a high level of language
interoperability
• common runtime engine shared by all .NET-
aware languages
• Programs written in different languages are all
compiled into MSIL (CIL) => language
independence
.NET-compliant languages
• http://www.dotnetlanguages.com/
APL Pascal RPG
C# Component Pascal DotLisp
Mondrian Curriculum Scheme
COBOL Forth Smalltalk
Eiffel Fortran Standard ML
Java Haskell Visual Basic
JScript Mercury Visual C++
Managed Jscript Oz IronPython
Oberon Perl IronRuby
The .NET Framework – Building blocks

Base Class Libraries

Common Language Runtime


Common Type System

Common Language Specification


The CLR
• Central part of the
.NET Fw. that executes
.NET programs
• Shared by all
compliant languages
• Provides:
– Memory management
– Exception handling
– Garbage collection
– Security
.NET Assemblies
• Code targeting the .NET runtime – managed
code
– Ex: C# produces code that executes only within
the .NET runtime
• The binary unit containing the code –
assembly
.NET Assemblies
• Same file extensions as COM servers & Win32
binaries (*.dll & *.exe)
• Different structure though
• An assembly contains:
– CIL code
– Metadata
– Manifest
The Assembly/Namespace/Type
Distinction
• Namespace = grouping of semantically related
types contained in an assembly
– Ex: System.IO, System.Collections
• The predefined .NET assembly: mscorlib.dll
• Object Browser
• Any language targeting .NET makes use of the
same namespaces and same types.
The role of the CIL (aka MSIL)
• Sits above any platform-specific instruction set
• Is emitted by all .NET-compliant language
compilers
– C# compiler
– VB compiler
– IronPython compiler a.s.o
• ildasm
Benefits of CIL
• Language integration
• Platform independence
• Further compiled into machine-specific
language using a just-in-time compiler that is
optimized for the underlying platform (ex.
Handheld device vs. back-end server)
The CTS
• describes all possible data types and programming
constructs supported by the runtime
• specifies how these entities can interact with each
other
• details how they are represented in the .NET metadata
format
• In the world of .NET, type is simply a general term used
to refer to a member from the set {class, interface,
structure, enumeration, delegate} + intrinsic types.
CTS Class Types
• The class type is the cornerstone of OOP.
• A class may be composed of any number of
members (such as properties, methods, and
events) and data points (fields).
• In C#, classes are declared using the class
keyword:

class Calc
{
public int Add(int x, int y)
{ return x + y; }
}
CTS Interface Types
• Interfaces – a named collection of abstract
member definitions, which may be supported
(i.e., implemented) by a given class or
structure.
• In C#, interfaces are defined using the
interface keyword:

public Interface IDraw


{
void Draw();
}
CTS Structure Types
• The user-defined types (UDTs) have survived in the world of .NET
• A structure can be thought of as a lightweight class type having
value-based semantics.
• Typically, structures are best suited for modeling geometric and
mathematical data, and are created in C# using the struct keyword:
struct Point
{
// Structures can contain fields.
public int xPos, yPos;

// Structures can contain parameterized constructors.


public Point(int x, int y)
{ xPos = x; yPos = y;}

// Structures may define methods.


public void Display()
{
Console.WriteLine("({0}, {1}", xPos, yPos);
}
}
CTS Enumeration Types
• Enumerations – handy programming constructs
that allow you to group name/value pairs.
• Rather than keeping track of raw numerical
values to represent each possibility, you could
build a custom enumeration using the enum
keyword:
enum CharacterType
{
Wizard = 100,
Fighter = 200,
Thief = 300
}
CTS Delegate Types
• Delegates – the .NET equivalent of a type-safe C-style
function pointer.
• The key difference is that a .NET delegate is a class that
derives from System.MulticastDelegate, rather than a
simple pointer to a raw memory address.
• In C#, delegates are declared using the delegate
keyword:
delegate int BinaryOp (int x, int y);

• Delegates are useful when you wish to provide a way


for one entity to forward a call to another entity, and
provide the foundation for the .NET event architecture.
The CLS
• A related specification that defines a subset of
common types and programming constructs
that all .NET programming languages can
agree on.
• For example, the CLS describes
– how a given language must represent text strings,
– how enumerations should be represented
internally (the base type used for storage),
– how to define static members, a.s.o.
The Platform-Independent Nature of
.NET
• .NET assemblies can be developed and
executed on non-MS operating systems
• Open-source .NET Distributions:
– The Mono project (various Linux distributions,
Win32, Mac OS X)
• www.mono-project.com
– Portable.NET (Win32, AIX, BeOS, Mac OS X, Linux)
• www.dotgnu.org
Summary
• C#
• .NET Framework and its building blocks
• .NET Assemblies
• Common Intermediate Language
• Data Types supported by .NET
• .NET Platform independence
Bibliography
• Deitel & Associates: Visual C#® 2005: How to
Program, Second Edition. Prentice Hall, 2005
• John Sharp: Microsoft Visual C#® 2008 Step by
Step. Microsoft, 2008
• Andrew Troelsen: Pro C# 2008 and the .NET
3.5 Platform, Fourth Edition Apress, 2008
• www.wikipedia.org
? ? ?
?
?

?
? ? ?
?
? ? ? ?

?
? ?
?
?
? ?
Thank you!

You might also like