+ All Categories
Home > Technology > Hidden Facts of .NET Language Gems

Hidden Facts of .NET Language Gems

Date post: 26-Aug-2014
Category:
Upload: abhishek-sur
View: 1,034 times
Download: 15 times
Share this document with a friend
Description:
Helloworldgeeks organized event on Language internals.
Popular Tags:
19
Hidden facts of .NET 4.5 language gems By Abhishek Sur Website: www.abhisheksur.com Email : [email protected]
Transcript
Page 1: Hidden Facts of .NET Language Gems

Hidden facts of .NET 4.5 language gems

By Abhishek Sur

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

Page 2: Hidden Facts of .NET Language Gems

.NET Infrastructure

User InterfaceASP.NET

(Web Forms, MVC,

Dynamic Data)

Windows Presentation Foundation

Win Forms

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

Objects

Page 3: Hidden Facts of .NET Language Gems

Agenda

Language GEMS

Iterators

Delegates

Events

Generics

Extension Methods

LINQ

Dynamic Types

Async

Page 4: Hidden Facts of .NET Language Gems

What are loops ? A repetition of instructions ? A logical jump in code Or a representation of GoTo with a

condition…Types of Loops While do-while for goto ?... Lets take an example

Page 5: Hidden Facts of .NET Language Gems

Iterators in .NET Represented by IEnumerable and

IEnumerator (which is not a collection) Ability to Pause – Resume a method. foreach is a syntactic sugar to iterate over

an iterator. Yield is used to generate an iterator

Page 6: Hidden Facts of .NET Language Gems
Page 7: Hidden Facts of .NET Language Gems

Iterators

Demo

Page 8: Hidden Facts of .NET Language Gems

Delegates Delegates are special types Delegate points to Methods MulticastDelegates maintains an Invocation

List

Events Events are Wrappers to Delegates Cleaner pattern to handle Delegates Allows components to subscribe to it by

passing event handlers.

Page 9: Hidden Facts of .NET Language Gems

Delegates & Events

Demo

Page 10: Hidden Facts of .NET Language Gems

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

Delegates etc. Variance is supportedExtension Methods Extend your predefined Types without

inheritance Uses ExtensionAttribute to identify extension

method.

Page 11: Hidden Facts of .NET Language Gems

Generics & Extension Methods

Demo

Page 12: Hidden Facts of .NET Language Gems

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 13: Hidden Facts of .NET Language Gems

Anonymous Types & LINQ

Demo

Page 14: Hidden Facts of .NET Language Gems

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 15: Hidden Facts of .NET Language Gems

Dynamic

Demo

Page 16: Hidden Facts of .NET Language Gems

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 17: Hidden Facts of .NET Language Gems

Async & Await

Demo

Page 18: Hidden Facts of .NET Language Gems

Exposing the Compiler Ability to run compiler as a service. Syntax tree, Binder, Expression all are

available through code.

Page 19: Hidden Facts of .NET Language Gems

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

Abhishek Sur, MVP (Client App Dev)


Recommended