Why do I Love C#?

18
Why I Love C#.NET… By Abhishek Sur Website: www.abhisheksur.com Email : [email protected]

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#?

Page 1: Why do I Love C#?

Why I Love C#.NET…By Abhishek Sur

Website: www.abhisheksur.comEmail : [email protected]

Page 2: Why do I Love C#?

.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

Page 3: Why do I Love C#?

Agenda

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

Language

Features of C#

Page 4: Why do I Love 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

Page 5: Why do I Love C#?

Delegates & Events

Demo

Page 6: Why do I Love C#?

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

Page 7: Why do I Love C#?

Generics & Extension Methods

Demo

Page 8: Why do I Love C#?

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)

Page 9: Why do I Love C#?

Iterators

Demo

Page 10: Why do I Love C#?

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…

Page 11: Why do I Love C#?

Anonymous Types & LINQ

Demo

Page 12: Why do I Love C#?

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

Page 13: Why do I Love C#?

Dynamic

Demo

Page 14: Why do I Love C#?

Going Beyond… (Async)

Page 15: Why do I Love C#?

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

Page 16: Why do I Love C#?

Async & Await

Demo

Page 17: Why do I Love C#?

Do you love C# now?

Page 18: Why do I Love C#?

Thank you.Twitter : @abhi2434Email: [email protected]

Abhishek Sur, MVP (Client App Dev)