Friday, July 6, 2007

.NET User Group meeting 4 Jul 2007

What’s new in VB9

  • Philip Cox
  • Senior Developer
  • Trade Me Ltd

http://www.ribboncustomizer.com/

  • RCWOUG1
  • 15% discount until 19 July

Brief history

  • 1991 – Microsoft VB1 for Windows
  • 1998 – VB6
    • Easy to learn and use
    • Quick to create Windows GUI applications
    • Get’s picked on by lower level languages
  • 2002 – VB7
    • .Net 1.0
    • Garbage collection, structured error handling…
    • All the tools of the.net framework
    • Get’s picked on by C#
  • 2003 – VB 7.1
  • 2005 – VB 8
    • Edit and Continue
    • The My namespace
    • Generics
    • And more…

Implicitly Typed Local Variables

  • E.g “Dim memberId = 31719”
  • A switchable option

Object Initializers

  • Set properties of an object at the time of instantiating the object
  • Uses WITH

Collection Initializers

  • Dim x = {2, 4 ,5, 7}

Extension Methods

  • <Extension()> Function name(value as objectType) as outputType… End Function
  • Extends the object type (e.g. string)

Lambda Expressions

  • Not in Orcas Beta1 for VB
  • Is there for C#
  • Pointers to functions

Anonymous Methods (C#2.0)

  • The old way of doing Lambda Expressions
  • Take an object and return a function of that object
  • E.g. CalcLength lengthFunction = t => t.Length;
  • Console.WriteLine(“{0}”, lengthFunction(“Hi!”));

Anonymous Types

  • Var anon = new { firstName=”Phil”, LastName=”Cox”};
  • Dim anonymousType = New With (.FirstName=”Phil”, .LastName=”Cox”}

Deep XML Support

  • (C# does have)
  • Dim xml = _
    • <?xml versoin =”1.0”?>
    • <CoolNewFeatures name=”Nullabletype”>
  • Not in Orcas Beta1

LINQ (Language Integrated Query)

  • LINQ To Objects
  • LINQ Enabled ADO.net
    • LINQ To datasets
    • LINQ To SQL
    • LINQ To entities
  • LINQ to XML
    • FROM first (for IntelliSense)
    • WHERE <% entity.attribute %>
    • SELECT <xml>
  • LINQ to Objects too

Nullable Types

  • Not in Orcas Beta1 for VB
  • Int? nullableInt;
  • If(nullableInt == null) {}
  • Int I =

Relaxed Delegates

  • (only in VB)
  • AddHandler button1.Click, AddressOf clickEvent
  • Private Sub ClickEvent() ‘No need to specify arguments

Partial Methods

  • Not in Orcas Beta1 for VB
  • Can redefine methods in same class
  • Must be sub (or void) because sometimes it will return a value and other times it won’t
  • Can only be one stub and one implementation
  • If more than one implementation, compile error

Automatic Properties

  • Not in VB at all
  • Public class Person {
  • Public string FirstName {get; set;}
  • Public string LastName { get; set; }
  • Public int Age (get; set; }
  • }

And more!

  • Turnery “If”
  • Coalesce operator
  • Improved IntelliSense
  • “My” extensions
  • And more…

What’s new in C# 3.0

  • Kirk Jackson
  • Senior Developer
  • Xero

Agenda

  • A brief history
  • What’s new
  • Questions

Brief history

  • Pre 2000 – Other programming languages ruled the world
  • June 2000 – C# Announced at PDC
    • Beta version released
    • No comparisons to Java are made
    • ECMA Standardisation
  • 2001 – Mono C#
  • 2002 – Wellington .NET User Group
  • 2003 – VS .NET 2003
  • 2005 – VS .Net 2005
  • 2006 - .NET Framework 3.0
  • 2008 – C#3.0

Questions

  • Is it time to switch back to VB? That XML stuff looks pretty good.
  • Personally can’t see any difference/reason to change
  • Do C# developers get paid more?
    • There is prejudice against VB
    • However, there is a shortage of VB
    • Perhaps C# developers come from a Comp Sci (academic) background
    • Perhaps VB developers come from a Comm (business) background
    • Perhaps managers get paid more?

No comments:

Post a Comment