Why do I Love C#?
-
Upload
abhishek-sur -
Category
Technology
-
view
1.518 -
download
9
description
Transcript of Why do I Love C#?
Why I Love C#.NET…By Abhishek Sur
Website: www.abhisheksur.comEmail : [email protected]
.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: [email protected]
Abhishek Sur, MVP (Client App Dev)