Why do I Love C#?

Post on 26-Aug-2014

1.519 views 9 download

Tags:

description

In this session I have discussed what are the major features that makes me love C# as a language. I presented this in front of 250 audiences in Jadavpur University campus.

Transcript of Why do I Love C#?

Why I Love C#.NET…By Abhishek Sur

Website: www.abhisheksur.comEmail : contact@abhisheksur.com

.NET Infrastructure

User InterfaceASP.NET

(WebForms, MVC,

Dynamic Data)

Windows Presentation Foundation

WinForms

Core

Services

Base Class Library

Common Language Runtime

Windows Workflow

Foundation

Windows Communicati

on Foundation

Data Access

Entity Framework

LINQ

ADO.NET

LINQ to SQL

Dynamic Async

Data Services (ODATA)

Generics

Cloud

Agenda

• Delegates• Events• Generics• Iterators• Extension Methods• LINQ• Dynamic Types• Async

Language

Features of C#

Delegates Delegates are special types Delegate points to Methods Delegates are not Function Pointers

Events Events are Wrappers to Delegates Cleaner pattern to handle Delegates Only use when you do require

Delegates & Events

Demo

Generics Type as Template Constraint on Generic Types It can be applied on Types, Method,

Delegates etc.

Extension Methods Extend your predefined Types without

inheritance Available when appropriate namespace is

available

Generics & Extension Methods

Demo

Iterators Forms a State Machine which can pause –

Continue a method. We create Itreators using yield keyword in

C# which generates an IEnumerable. Any Collection can be represented by

Ienumerable Iterators represents a sequence (finite /

Infinite)

Iterators

Demo

Anonymous Language Object

LINQ

Object can exist in language without name Cleaner codebase. Anonymous methods are used as Closures. We use delegate to refer anonymous

methods and var for types.

Search inside Managed objects Simple projection, selection, grouping, joins

and many more…

Anonymous Types & LINQ

Demo

Dynamic in .NET 4.0 CLR is mostly static type

◦ Compile time type checking DLR added dynamism to .NET

◦ Run time type checking Object – Static type, base class var – is ALSO static type, compiler inferred dynamic – Evaluation deferred Expandable objects

Dynamic

Demo

Going Beyond… (Async)

New Asynchronous Pattern

Contextual async & await pattern simplifies complex Threading model or existing pattern of coding

Async is not about Concurrency but rather it is truly asynchrony.

It can easily plugged in without changing the logic.

Compiler generates state machine to resume methods

Async & Await

Demo

Do you love C# now?

Thank you.Twitter : @abhi2434Email: contact@abhisheksur.comwww.abhisheksur.com

Abhishek Sur, MVP (Client App Dev)