1 / 23

Upgrading Your C# Programming Skills to Be a More Effective Developer

DEV318. Upgrading Your C# Programming Skills to Be a More Effective Developer. Mark Michaelis Lucian Wischik Chief Computer Nerd Senior Program Manager IntelliTechture Microsoft. About Us. Mark Michaelis Lucian Wischik IntelliTechture Microsoft

asis
Download Presentation

Upgrading Your C# Programming Skills to Be a More Effective Developer

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. DEV318 Upgrading Your C# Programming Skills to Be a More Effective Developer Mark Michaelis Lucian Wischik Chief Computer Nerd Senior Program Manager IntelliTechture Microsoft

  2. About Us Mark Michaelis Lucian Wischik IntelliTechture Microsoft Chief Computer Nerd, Senior Program Manager onAuthor & Trainer Languages Team

  3. Agenda C# 1.0 C# 2.0 C# 3.0 C# 4.0

  4. Auto-implemented PropertiesA Simplified Syntax • Reduce code clutter • Use everywhere for properties that are • Not Calculated • Don’t require interception (like validation) Call to Action • Use everywhere a simple property with backing field is used C# 2.0

  5. Optional and Named Parameters • Reduce the need for overloading • Makes Office COM interoperability much easier Call to Action • Available in place of overloading C# 4.0

  6. From object … to <T> • Replaces runtime errors with compile time errors • Reduces need for boxing especially with collections • Intellisense returns Call to Action • object is suspicious (indicates code smell) • Rely on implied type parameters unless overloaded with non-generic type that uses object • Favor generic collections (like List<T>) over arrays C# 2.0

  7. Collection Initializers • Enable array like initialization with generic types • Type must support an Add<T>(T item) method Call to Action • Favor in place of arrays C# 3.0

  8. Nullable<T> / int? • Allow for values types to store null • Implicitly cast value type to nullable type • Explicitly cast nullable type to value type • Supports coalesce operator (??) Call to Action • Use whenever a value type needs to store null C# 2.0

  9. Generic Constraints • Avoid runtime cast exceptions • May be combined with as logical AND constraints • Support class (reference type) and struct (value type) Call to Action • Use to in place of explicit cast operations C# 2.0

  10. yield return • Simplifies collection (IEnumerable<T>) implementation • Used infrequently but invaluable when used Call to Action • Consider yield return for custom IEnumerable<T>implementation or IEnumerable<T> return parameter. C# 2.0

  11. Extension Methods • Extend types you don’t control • Used infrequently but invaluable when used Call to Action • Use gingerly • Restrict to interfaces that you don’t control or can’t be changed C# 3.0

  12. Generic Delegates • Reduces the need to declare delegates Call to Action • Favor EventHandler<T>, Action<T, …>, Func<T, …> • Only declare delegates to clarify type parameters C# 2.0/3.0

  13. Lambda Expressions • Replace explicit method declaration • Useful when delegate parameter varies frequently • Enables “passing” local variables without parameters or class members • Available in both expression and statement forms Call to Action • Embrace lambda expressions/statements • Favor lambdas over anonymous methods from C# 2.0 C# 3.0

  14. LINQ • Transforms collection API • Available via standard query operators or query expressions • Enables object relational mapping • Fully strongly typed Call to Action • Embrace LINQ • Avoid uninttended deferred execution C# 3.0

  15. Implicitly Typed Local Variables • Required for anonymous types • Equivalent to using the explicit types when available • Must be assigned at declaration time Call to Action • Only use when required or when the data type is obvious • Avoid when data type is complex (unless using anonymous types) C# 3.0

  16. Contact Info. Mark Michaelis Lucian Wischik IntelliTechture Microsoft Chief Computer Nerd, Senior Program Manager onAuthor & Trainer Languages Team mark@IntelliTechture.com

  17. DEV Track Resources • http://www.microsoft.com/visualstudio • http://www.microsoft.com/visualstudio/en-us/lightswitch • http://www.microsoft.com/expression/ • http://blogs.msdn.com/b/somasegar/ • http://blogs.msdn.com/b/bharry/ • http://www.microsoft.com/sqlserver/en/us/default.aspx • http://www.facebook.com/visualstudio

  18. Resources • Connect. Share. Discuss. http://northamerica.msteched.com Learning • Sessions On-Demand & Community • Microsoft Certification & Training Resources www.microsoft.com/teched www.microsoft.com/learning • Resources for IT Professionals • Resources for Developers http://microsoft.com/technet http://microsoft.com/msdn

  19. Complete an evaluation on CommNet and enter to win!

  20. © 2011 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

More Related