introduction to c# 3.0

23
Overview of C# 3.0 Presentation created by Eriawan Kusumawardhono, for RX Communica

Upload: eriawan-kusumawardhono

Post on 10-May-2015

532 views

Category:

Technology


1 download

DESCRIPTION

C#

TRANSCRIPT

Page 1: Introduction to C# 3.0

Overview of C# 3.0

Presentation created by Eriawan Kusumawardhono, for RX Communica

Page 2: Introduction to C# 3.0

C# 3.0 is?

A part of .NET programming languages from Microsoft

It is released with Visual Studio 2008 and .NET 3.5

Page 3: Introduction to C# 3.0

Historical perspective of C# 3.0A quick tour of historical view

Page 4: Introduction to C# 3.0

Beginning of C#

C# was a first managed language to compete with Java

Microsoft was lost in court because of J++ implementation

C# 1.0 was designed and developed in 1999

C# 1.0 has basic OOP of inheritance, polymorphism

Property mechanism is the same concept as VB 4.0+

Page 5: Introduction to C# 3.0

C# is?

Statically typed language Early bound Based on CLR and CTS of .NET Also part of “curly braces” languages

such as C, C++, Objective C, Java Imperative language as part of OOP

Page 6: Introduction to C# 3.0

Managed language is simply virtualization

Just like Java runs in its VM Virtualization promotes cleaner

environment, optimization, garbage collection, thread optimization within one “virtual” platform

A light lose coupling between OS and application written in managed environment or virtualization

Reduced OS version dependency and functionality

Page 7: Introduction to C# 3.0

So why?

It is simply, raising an abstraction, not adding abstraction

Focusing more on what you want to be done, not how

Page 8: Introduction to C# 3.0

The sample of adding abstraction: batch command

DOS batch command

Console API

USER32 API

Page 9: Introduction to C# 3.0

Raising level of abstraction

Assembly

Procedural

OOP

Managed environment

Page 10: Introduction to C# 3.0

Conceptual difference of abstraction

RAISING ABSTRACTION

Intended to be more declarative

Does not hide the detail of underlying platform

Still can access the OS API using P/Invoke in .NET and JNI in Java

ADDING ABSTRACTION

Not intended to be more declarative

Often creating more new conceptual topics

Often hide the detail of the underlying platform

Page 11: Introduction to C# 3.0

What comes with C# 2.0

Adding generics on type and method declaration

Generic type inference on methods and method parameters

Reflection granularity Nullable types Iterator of “yield” Anonymous delegate

Page 12: Introduction to C# 3.0

Current release of C#: 3.0Present state of C# (2009)

Page 13: Introduction to C# 3.0

Continuous design from previous releases

New features are based on previous releases

Maintaining runtime compatibility and based on CLR of .NET 2.0

Page 14: Introduction to C# 3.0

C# 3.0 theme

LINQ Functional programming in style

Page 15: Introduction to C# 3.0

LINQ is build on

Query comprehension Extension method Lambda expression Expression tree Property initializer Anonymous type initializer Local variable type inference

Page 16: Introduction to C# 3.0

Quick feature look

var x = from c in db.customer where c.City ==“London” select c.Name, c.City

var x = db.Customer .Where(c => c.City == “London”) .Select(c=> new {c.Name,c.City}

Query comprehension

Local type infer

Extension method

Lambda expression

Anonymous object/type initializer

Page 17: Introduction to C# 3.0

Query comprehension

Adapting SQL query of SELECT Not a real keyword in C#, it is a

pseudo keyword SELECT, WHERE, ORDER BY, GROUP

BY is then translated into calls to extension methods

Page 18: Introduction to C# 3.0

Lambda Expression overview

It is simply an anonymous delegate but with the functional math syntax

Taken from ideas in Lambda calculus

Page 19: Introduction to C# 3.0

Extension methods

Adding static method to a class or interfaces without deriving it

Use it wisely Can be a bad smell in coding

practice

Page 20: Introduction to C# 3.0

Next is: C# 4.0Main theme: support for dynamic type

Page 21: Introduction to C# 3.0

Overview of C# 4.0

Dynamic type Co and Contra variance Optional and named parameters No PIA

Page 22: Introduction to C# 3.0

Beyond C# 4.0

Compiler as a service True meta programming Method execution into multi core

(parallel) Function purity

Page 23: Introduction to C# 3.0

End