Net framework

Post on 10-May-2015

378 views 3 download

Tags:

Transcript of Net framework

Introduction to .NET Framework 3.5 and

C# 3.0

tnngo2@gmail.com

Programming in C#

A look back …

.NET 1.0 .NET 1.1 .NET 2.0

3.0 3.5

.NET 4

2002 2003 2008 CTP 2005-08

CLR 1.0 CLR 1.1 CLR 2.0 CLR 4

Architecture

Base Class Libraries

The CLR JIT &

NGEN Garbage Collector

Security Model

Exception Handling

Loader & Binder

WPF Win Forms DLR ASP.NET WCF And

more! LINQ

JIT in execution before executing hybrid approach

Interpreted compilation

Static compilation

Just-in-time Compilation

NGEN use native image from cache instead using JIT compilation

Loader & Binder locating assemblies at run-time and binding to them.

WPF – Windows Presentation Foundation graphical subsystem for rendering UI in windows-based application Silverlight utilizes WPF to provide embedded web controls comparable to Adobe Flash but more focus on an UI object model and less on animation.

WCF – Windows Communication Foundation designing and deploying distributed applications under services- oriented architecture (SOA) implementation

set of principle and methodologies for interoperable application

DLR – Dynamic language runtime a runtime environment that adds a set of services for dynamic languages to the common language runtime (CLR) Dynamic language identify the type of object at runtime whereas in statically type languages must specify object type at design time

https://gist.github.com/2627105

New features of C# 3.0

Implicitly Typed Local Variables declare variables without specifying the type at design time Must be declared and initialized at the same time. Cannot used as a return type and argument of method. Not possible for multiple declaration

var age; // Error, no initializer to infer the data type var age = 5; // Valid

var age = 1, genre = “male”; // Error

Object Initializers

Creates an object and initialize its fields and properties without a constructor

https://gist.github.com/2627433

Auto-implemented Properties

Creates an object and initialize its fields and properties without a constructor

public string HouseName { get; set; }

Extension Methods

Allows you to extend an existing type with new functionality without directly modifying those types Are static methods that have to be declared in a static class Declare an extension method by specifying the first parameter with this keyword

https://gist.github.com/2627468

static return-type MethodName (this type obj, param-list)

Collection Initializers

ClassName objName = new CollectionClassName{ collection-initializer }

Predefined Generic Delegates Func<T, TResult>() Delegate Represents a method having one parameters type T and returns a value of type TResult

https://gist.github.com/2627640

public delegate TResult Func<TResult>()

Lambda Expressions is an alternative to anonymous methods. https://gist.github.com/2633475

parameter-list => expression or statements