eric vogel software developer a.j. boggs & company
TRANSCRIPT
What’s new?New Projects for .NET 3.0 and 3.5Framework build targetingJavascript IDE enhancementsBuilt in Unit Testing! New language additions to C# and VB
New ProjectsWindows
WPF Web
ASP.NET AJAXWCF Service
OfficeOffice 2007
WorkflowSmart Device
Target .NET 2.0,3.0, and 3.5 Compact Frameworks.Windows Mobile 5.0, 6.0 SDK as free download.
.NET 3.0Windows Presentation Foundation (WPF)
Windows Forms replacement. Controls are expressed in XAML.Provides a more expressive UI layer for
applications.Windows Communication Foundation (WCF)
Bridges networking APIs (Web Services, .NET Remoting,..) into one API.
Very configurable, supports multiple transport layers such as http and tcp.
SOAP 1.1 and 1.2 complient.
.NET 3.0 (continued)Work Flow (WF)
Allows graphical design of sequences and state machines.
Good for expressing business processes.Card Space
Security identification service that stores users identification information.
WCF supports Card Space.
.NET 3.5 New language additions to C# 3.0 and
VB .NET 9.0LINQ ASP .NET AJAXWF support in WCF Services
Host Work Flow in a WCF Service
Framework build targetingCompile projects to target a specific .NET
Framework.Supports .NET 2.0,3.0, and 3.5
Unit TestingOnly included in Pro and Team Editions.Can create tests for Web, Desktop, and
Mobile applications.Demo
New in C# and VB .NETImplicitly typed local variablesObject intializersArray initializersAnonymous typesExtension MethodsLambda ExpressionsLINQ
Implicitly typed local variablesVariable declarator must have an intializerType is inferred by the initialization of the variableVariable cannot be initialized to nullExamples:
C#var foo = 5;var bar = “Hello GLUG .net”;var foobar = new List<int>();
VB Dim foo = 5;Dim bar = “Hello GLUG .net”;Dim foobar = New List(Of Integer)
Object initialzersInitialize properties and accessible members
of an object.Nice substitute for overloaded constructors.Can be embeddedExamples:
C#var voyager = new Ship{Capacity=1000, Shields=200};
VBDim voyager = New Ship With {.Capacity = 1000, .Shields = 200}
Implicitly typed arraysThe type of the array is determined by its
initialized content.Examples:
C# var scores = new[] { 50, 60, 70, 70, 80, 90, 100 };
VBDim scores() = { 50, 60, 70, 70, 80, 90, 100 }
Anonymous TypesCreate objects with anonymous types.Anonymous types inherit from Object.Examples:
C#var item = new { Id=10, ItemType="Game",
Cost= 29.99 };VBDim item = New With {.Id = 10, .ItemType =
"Game", .Cost = 29.99}
Extension MethodsStatic method that extends an existing class.Invoked as if it were an instance method of
the class being extended.Shadowed by member methods of the
extending class.Only allowed access to public members of the
extending class.
Extension Methods (C# example)Example:
public static class ExtensionMethods { public static bool GreaterThan(this int i, int n) { return i > n; } }
int num = 5;num.GreaterThan(2); // will return true, since 5 is greater than 2
Extension Methods (VB example)Example:
Imports System.Runtime.CompilerServices
Public Module ExtensionMethods <Extension()> _ Public Function GreaterThan(ByVal i As Integer, ByVal n As Integer)
As Boolean Return i > n End FunctionEnd Module
Dim num As Integer = 5 num.GreaterThan(2) ) ‘ will return true, since 5 is greater than 2
Lambda ExpressionsC# (input parameters) => { expression or statement block }VB Function(input parameters) expression or statement block
Provide a cleaner and more concise expression of anonymous methods.
Parameters can be explicitly or implicitly typed.Have a million and one uses!Demo
LINQ Language INtegration Query or LINQ
introduces the ability to query objects directly in the language.
Syntax is very similar to SQL.Visual Studio 2008 currently has LINQ to
SQL, LINQ to XML and LINQ to Objects.Demo of LINQ to Objects.
Collection InitializersCollection must implement IEnumerable.Each item is added to the collection behind
the scenes by calling the Add method of the collection.
Examples: List<string> names = new List<string> { “Eric”, “Jeff”, “Joe” };List<int> scores = new List<int> { 50, 60, 70, 70,
80, 90};
Automatic PropertiesMore concise way to create a Property with a
backing field.New default code snippet for prop in VS
2008.Examples:
public int NumDays { get; set; }public DateTime DueDate { get;
set; }
XML literals XML is able to be used as a literal.IntelliSense support, including schemas.Tight integration with LINQ to XML.Examples:
Dim products = <Products> <Product name="CodeSmart"> <Id>20</Id> </Product> </Products>
Dim appConfig = <?xml version="1.0" encoding="utf-8"?> <configuration> </configuration>
Relaxed DelegatesMethods no longer have to exactly match
their method delegate signatures.Methods can have a derived type of what is
defined in the delegate as a return type (covariance).
Methods can be passed arguments with types that are base classes of the arguments specified in the delegate signature (contravariance).
Covariance Example Public Class Record End Class
Public Class Person Inherits Record End Class
Public Delegate Function RecordChanged(ByVal Id As Integer) As Record
Public Function GetChangedRecord(ByVal Id As Integer) As Record Return New Record End Function
Public Function GetChangedPerson(ByVal Id As Integer) As Person Return New Person End Function
Sub Main()Dim changedPerson As RecordChanged = AddressOf GetChangedPerson
End Sub
Contravariance ExamplePublic Delegate Sub PersonSelected(ByVal Person)
Public Sub RecordSelected(ByVal Record) End Sub Sub Main() 'Contravariance Dim personPicked As PersonSelected =
AddressOf RecordSelected End Sub
[email protected]://ericvogel.comTwitter - @vogelvision
ReferencesOverview of C# 3.0
http://msdn.microsoft.com/en-us/library/bb308966.aspx#csharp3.0overview_topic1
Overview of Visual Basic 9.0http://msdn.microsoft.com/en-us/library/
ms364068(vs.80).aspx#vb9overview_topic1Programming C# 3.0
Jesse Liberty & Donald Xie, O’ReilyThe LINQ Project
http://msdn.microsoft.com/en-us/netframework/aa904594.aspx