1 / 28

Visual Studio 2010 and .NET Framework 4 Training Workshop

Visual Studio 2010 and .NET Framework 4 Training Workshop. What’s New In C# 4.0 and Visual Basic 10. Name Title Organization Email. Essence versus Ceremony Simple, Concise, Expressive. Ceremony in C# 3.0. Removing “magic values” via temporary variables. GenerateChart (20, true);.

redford
Download Presentation

Visual Studio 2010 and .NET Framework 4 Training Workshop

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. Visual Studio 2010and.NET Framework 4Training Workshop

  2. What’s New InC# 4.0 and Visual Basic 10 Name Title Organization Email

  3. Essence versus Ceremony Simple, Concise, Expressive

  4. Ceremony in C# 3.0 Removing “magic values” via temporary variables GenerateChart(20, true); varprocessCount = 20; varcopyToWord = true; GenerateChart(processCount, copyToWord);

  5. Ceremony in C# 3.0 Removing “magic values” via temporary variables GenerateChart(20, true); GenerateChart(20 /* processCount */, true /* copyToWord */);

  6. Ceremony in C# 3.0 Optional parameters via method overloading void GenerateChart(intprocessCount) { GenerateChart(processCount, false); } void GenerateChart(intprocessCount, boolcopyToWord) { // Do Something }

  7. Ceremony in C# 3.0 Ugly COM Interop and the ever-present “ref Missing.Value” var word = new Word.Application(); word.Documents.Add(ref Missing.Value, ref Missing.Value, ref Missing.Value, ref Missing.Value);

  8. Essence vs. Ceremony in C# 4.0

  9. Ceremony in VB 9 Backing fields for properties are explicit Private m_name As String Public Property Name() As String Get Name = m_name End Get Set (ByVal value As String) m_name = value End End Property

  10. Ceremony in VB 9 Popularity of lambda-based libraries cause problems for VB developers Sub MyMethod() LambdaCall(Function(i) TempMethod(i) End Function) End Sub Function TempMethod(Dim param as Integer) As Nothing Console.WriteLine(param) Return Nothing End Function Introduction of temporary functions “Hacks” since statement lambdas not supported

  11. Ceremony in VB 9 Line continuations must be specified by the developer SomeLongMethodCall(firstParam, _ secondParam, _ thirdParam, _ fourthParam, _ fifthParam)

  12. Essence vs. Ceremony in VB 10

  13. Why a “Dynamic Language Runtime”? Dynamically-Typed Ruby Python Statically-Typed VB C# Common Language Runtime

  14. Why a “Dynamic Language Runtime”? Dynamically-Typed Ruby Python Statically-Typed VB Dynamic Language Runtime C# Common Language Runtime

  15. Ceremony in C# 3.0 Dynamic Language interop is painful Calculator calc = GetCalculator(); int sum = calc.Add(10, 20);

  16. Ceremony in C# 3.0 Dynamic Language interop is painful object calc = GetCalculator(); Type calcType = calc.GetType(); object res = calcType.InvokeMember("Add", BindingFlags.InvokeMethod, null, new object[] { 10, 20 }); int sum = Convert.ToInt32(res);

  17. Ceremony in C# 3.0 Dynamic Language interop is painful ScriptObject calc = GetCalculator(); object res = calc.Invoke("Add", 10, 20); int sum = Convert.ToInt32(res);

  18. Essence in C# 4.0 Dynamic Language interop doesn’t have to be painful! Statically typed to be dynamic dynamic calc = GetCalculator(); int sum = calc.Add(10, 20); Dynamic method invocation Dynamic conversion

  19. The power of late-binding

  20. New Features in C# 4.0 &VB 10 New in Dev10 Already exists in VB9/C#3

  21. New Features in C# 4.0 &VB 10 New in Dev10 Already exists in VB9/C#3

  22. New Features in C# 4.0 &VB 10 New in Dev10 Already exists in VB9/C#3

  23. Fixing The Type System… Covariance and Contravariance… sounds complicated… But it’s not! sort of…

  24. Fixing The Type System… How are generic types “broken” today? class Animal { } class Sheep : Animal { } void Speak(IEnumerable<Animal> animals) { // Do something with Animals } Not Allowed: IEnumerable<Animal> != IEnumerable<Sheep> var sheep = new List<Sheep>(); Speak(sheep);

  25. Break it down… Covariance – think “out” Contravariance – think “in”

  26. Fixing The Type System… Covariance and Contravariance Sounds complicated! http://tinyurl.com/genericvariance

  27. Essence versus Ceremony

More Related