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.
1. By Abhishek Sur
Website: www.abhisheksur.com
Email : contact@abhisheksur.com
2. .NET Infrastructure
User Interface Services Data Access
ASP.NET
Windows Windows Windows
(WebForms, Entity
Presentation Communication Workflow ADO.NET
MVC, Dynamic Framework
Foundation Foundation Foundation
Data)
WinForms Data Services LINQ to SQL
Cloud
(ODATA)
Core
Generics LINQ Dynamic Async
Base Class Library
Common Language Runtime
3. Agenda
• Delegates
• Events
Language • Generics
• Iterators
Features • Extension Methods
of C# • LINQ
• Dynamic Types
• Async
4. 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
6. 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
8. 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)
10. Anonymous Language Object
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.
LINQ
Search inside Managed objects
Simple projection, selection, grouping, joins
and many more…
12. 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
15. 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