Revealing the Secrets of Self-Documenting Code Svetlin Nakov Telerik Corporation For C# Developers.
Revealing C# 5
-
Upload
praveen-prajapati -
Category
Education
-
view
1.170 -
download
0
description
Transcript of Revealing C# 5
Revealing C# 5
By- Praveen Kumar PrajapatiBlog: praveenprajapati.wordpress.com
AgendaBackgroundNew Features in C# 5Breaking ChangesAsynchronous ProgrammingCaller Info AttributesWindows Runtime Support (Metro Style apps)The Road Ahead
BackgroundVersion
Theme Year .NET Visual Studio
C # 1.0 Managed Code Jan 2002 1.0 VS .NET 2002
C # 2.0 Generics Nov 2005 2.0 VS 2005
C # 3.0 Language Integrated Query
Nov 2007 3.5 VS 2008
C # 4.0 Dynamic Apr 2010 4.0 VS 2010
C # 5.0 Asynchrony and Windows Runtime
Feb 2012 4.5 VS 2011
New Features in C# 5 Breaking Changes
Lambda expressionsLINQ expressionsNamed arguments
Asynchronous ProgrammingCaller Info AttributesWindows Runtime Support
Breaking ChangesLambda expressions: Use of iteration variable of a
foreach statement in a lambda expression that’s contained in the body of the loop
LINQ expressions: Use of iteration variable of a foreach statement in a LINQ expression that’s contained in the body of the loop
Named arguments: Side effects from named and positional arguments in a method call now occur in the correct order
Breaking ChangesDemo :
Lambda expressionsLINQ expressionsNamed arguments
Asynchronous ProgrammingNew Keyword introduces:
async await
Rules and recommendations for use of those keywords
Asynchronous Programming
public Task<XElement> GetXmlAsync(string url) { var tcs = new TaskCompletionSource<XElement>(); var client = new HttpClient(); client.GetAsync(url).ContinueWith(task => { var response = task.Result; var text = response.Content.ReadAsString(); tcs.SetResult(XElement.Parse(text)); }); return tcs.Task;}
public async Task<XElement> GetXmlAsync(string url) { var client = new HttpClient(); var response = await client.GetAsync(url); var text = response.Content.ReadAsString(); return XElement.Parse(text);}
Asynchronous ProgrammingDemo: Use of async and awaitHow it reduces efforts and make code better
Caller Info AttributesMore easily obtain information about the caller of
a method. By using Caller Info attributes, you can identify the file path of the source code, the line number in the source code, and the member name of the caller.
Demo: The use of Caller info attributesHow it reduces efforts and make code better
Windows Runtime SupportWindows Runtime: WinRT, is Microsoft's new programming
model that makes the backbone of the new Metro-style apps (also known as Immersive) in Windows 8 operating system
.NET APIs for Metro style apps provides a subset of managed types that you can use to create Metro style apps. This subset of managed types is called the .NET APIs for Metro style apps.
Deep integration with the Windows Runtime - a C# project can compiled into a WinMD file and then referenced from a HTML/JavaScript project.
What is Metro StyleMetro is the whole design language behind Windows
Phone, and is a big part of the future of Microsoft
Using clean, crisp, clear information to get information across as quickly and accurately as possible
Windows Metro style apps are designed for specific form factors and leverage the power of the Windows operating system.
Windows Metro style apps Metro style apps are immersive and chromeless, filling the entire
screen so there are no distractions.
Metro style apps work together, making it easy to search, share, and send content between them.
Metro style apps are tailored to your users' needs, to specific devices, to touch interaction and hardware events, and to the new Windows user experience in Windows 8 Consumer Preview.
Metro style design principlesMetro style design has a set of five guiding principles to help you make the best choices when designing your app. These principles are the foundation for building great Metro style apps.
Show pride in craftsmanshipBe fast and fluidBe authentically digitalDo more with lessWin as one
What is excludedThe subset of managed types and members was designed with a clear focus on Metro style app development. As a result, it omits the following:
Types and members that are not applicable to developing Metro style apps (such as console and ASP.NET types).
Obsolete and legacy types.Types that overlap with Windows Runtime types.Types and members that wrap operating system functionality (such
as System.Diagnostics.EventLog and performance counters).Members that cause confusion (such as the Close method on I/O
types).
Windows Runtime SupportDemo: Window Runtime support
The Road AheadCompiler as a serviceThe Roslyn ProjectCTP of Visual Studio Roslyn in mid October 2011C# interactive window“Paste as VB” and “Paste as C#”
Thanks to You AllLet us grow together
Keep in touch:Blog: praveenprajapati.wordpress.com