Transcript Document

C# Present and Future
Marita Paletsou
Software Engineer
Agenta
• Brief History
• C# 5.0 Basic Features
• .NET Compiler Platform
• New IDE Experience
• C# 6.0 New Features
Brief History
C# 5.0
C# 4.0
C# 3.0
C# 2.0
C# 1.0
VS 2002 - 2003
VS 2008 - 2010
Managed
Code
.NET 4.0
.NET 2.0
.NET 1.0 - 1.1
LINQ
Query & Lamda
Expressions
Extension Methods
Generics
Static Classes
Nullable Types
Anonymous Methods
.NET 4.5
VS 2010
.NET 3.0 - 3.5
VS 2005
VS 2012 - 2013
TPL
DLR
Named & Optional
Params
async + await
Caller Info
Synchronous vs Asynchronous
Synchronous:
• Execution in a single series
• Wait one task to finish before move to another
• Bad User Experience
Asynchronous:
• Run time-consuming operations concurrently
• Return as soon as an operation is completed
• Better User Experience
Asynchronous Programming Patterns
• Asynchronous Programming Model
• BeginMethodName and EndMethodName
• Event-based Asynchronous Pattern
• MethodNameAsync and MethodNameCompleted
• Task-based Asynchronous Pattern
• Single method returns Task or Task<TResult>
async + await
• Return types:
• Task<TResult>
• Task
• void
• Let compiler do the hard work
• How does it work?
async void
• Only for event handlers
• Caller has no information when async void is
completed
• Caller is unable to catch exceptions from an async
void
Demo
Caller Infromation Attributes
• Debugging, tracing, error handling in runtime
• Argument types:
• [CallerMemberName]
• [CallerFilePath]
• [CallerLineNumber]
• Apply to optional parameters
Demo
Opening up
• VS 2013 Community Edition - Free full featured IDE
• .NET Server Core
• “Roslyn” Compiler
New IDE Experience
• Quick Fixes
• Renaming Tool
• Introduce Local
• Colorization
• Quick Info
• Signature Help
C# 6.0 New Features (1)
• Using Static Classes
using System.Console; WriteLine("My message");
• Await Calls in catch and finally
try { //Do some work }
catch (Exception ex) { await Task.Delay(200); }
finally { await Task.Delay(200); };
• Exception Filters
catch (Exception ex) if (ex.Message.Contains("Cannot divide"))
• Null Conditional Operator
member operator: ?.
index operator: ?[]
C# 6.0 New Features (2)
• nameof Expressions
• throw new ArgumentNullException(nameof(value));
• Dictionary Initializers
var myDict = new Dictionary<int, string>() { [1] = "My Name" };
• Auto-Property Initializers
Only Getter: public Guid guid { get; } = new Guid();
Getter/Setter: public int studentYearOfBirth { get; set; } = 1993;
• Epression Bodied Properties & Functions
public string firstName => string.Format("{0} {1}", firstNm, lastNm);
public int age() => DateTime.Now.Year - yearOfBirth;
Demo
Useful Links
Visual Studio 2013 Community Edition:
http://www.visualstudio.com/products/visual-studio-community-vs
Visual Studio 2015 Preview & .NET 4.6 Preview:
http://www.visualstudio.com/en-us/downloads/visual-studio-2015downloads-vs
“Roslyn” Compiler:
http://roslyn.codeplex.com/
http://source.roslyn.codeplex.com/
MVA
Microsoft Virtual Academy for Devs
/app development/
/game development /
/web development /
/mobile development /
/cloud development /
/C#-XAML-HTML/
/visual studio και πολλά άλλα…
www.microsoftvirtualacademy.com
Όλα τα trainings που χρειάζεσαι δωρεάν σε ένα site!
Session Evaluation
2
ways
Your feedback is
important and valuable
to access
Go to
m.itprodevconnections.gr
Submit before the event’s
close session to WIN
prizes
Ask for an Evaluation Sheet from
the registration desk
Get In Touch
www.facebook.com/marita.paletsou
@MaritaPaletsou
www.codespot.gr
[email protected]
Q&A
Questions And Answers
Thank you!