Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Revealing C# 5


Published on

New Features in C# 5

Published in: Education, Technology
  • Be the first to comment

Revealing C# 5

  1. 1. By- Praveen Kumar Prajapati Blog:
  2. 2. Agenda Background New Features in C# 5 Breaking Changes Asynchronous Programming Caller Info Attributes Windows Runtime Support (Metro Style apps) The Road Ahead
  3. 3. BackgroundVersion Theme Year .NET Visual StudioC # 1.0 Managed Code Jan 2002 1.0 VS .NET 2002C # 2.0 Generics Nov 2005 2.0 VS 2005C # 3.0 Language Integrated Nov 2007 3.5 VS 2008 QueryC # 4.0 Dynamic Apr 2010 4.0 VS 2010C # 5.0 Asynchrony and Feb 2012 4.5 VS 2011 Windows Runtime
  4. 4. New Features in C# 5 Breaking Changes  Lambda expressions  LINQ expressions  Named arguments Asynchronous Programming Caller Info Attributes Windows Runtime Support
  5. 5. Breaking Changes Lambda 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
  6. 6. Breaking Changes Demo :  Lambda expressions  LINQ expressions  Named arguments
  7. 7. Asynchronous Programming New Keyword introduces:  async  await Rules and recommendations for use of those keywords
  8. 8. Asynchronous Programmingpublic 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);} 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; }
  9. 9. Asynchronous Programming Demo: Use of async and await How it reduces efforts and make code better
  10. 10. Caller Info Attributes More 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 attributes How it reduces efforts and make code better
  11. 11. Windows Runtime Support Windows Runtime: WinRT, is Microsofts 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.
  12. 12. What is Metro Style Metro 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.
  13. 13. 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.
  14. 14. Metro style design principlesMetro style design has a set of five guiding principles to help you makethe best choices when designing your app. These principles are thefoundation for building great Metro style apps. Show pride in craftsmanship Be fast and fluid Be authentically digital Do more with less Win as one
  15. 15. What is excludedThe subset of managed types and members was designedwith a clear focus on Metro style app development. As aresult, 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).
  16. 16. Windows Runtime Support Demo: Window Runtime support
  17. 17. The Road Ahead Compiler as a service The Roslyn Project CTP of Visual Studio Roslyn in mid October 2011 C# interactive window “Paste as VB” and “Paste as C#”
  18. 18. Thanks to You AllLet us grow together Keep in touch: Blog: