Visual Studio 2010and
.NET Framework 4
Training Workshop
Visual Studio 2010and
.NET Framework 4
Training Workshop
What’s New InC# 4.0 and Visual Basic
10
What’s New InC# 4.0 and Visual Basic
10NameTitleOrganizationEmail
Where We’re At TodayWhere We’re At Today
Our managed languages are starting to share some very similar features:
Functional
Concise
Declarative
Before
IList<Person> FindParentsWithChildNamed(string childName)
{var matches = new List<Person>();
foreach(var person in _people) { foreach(var child in person.Children) { if (child.Name.Equals(childName)) { matches.Add(person); break; } }
}return matches;
}
LINQ, The Power of Declarative
LINQ, The Power of Declarative
IList<Person> FindParentsWithChildNamed(string childName) { var matches = from person in people from child in person.Children where child.Name.Equals(childName) select person;
return matches.ToList();}
After
LINQ, The Power of Declarative
LINQ, The Power of Declarative
Why Declarative Matters…Why Declarative Matters…
Imperative Declarative
What
How
Addressing Language TrendsAddressing Language Trends
Declarative
Concurrent
Dynamic
The Evolution of C#The Evolution of C#
C# 1.0
C# 2.0
C# 3.0
Managed Code
Generics
LINQ
C# 4.0
Dynamic
New C# 4.0 FeaturesNew C# 4.0 Features
1. Late-Binding Support
2. Named and Optional Parameters
3. Improved COM Interop
4. Covariance and Contravariance
Simplifying Your Code with C# 4.0
Simplifying Your Code with C# 4.0
Co-evolving C# and VBCo-evolving C# and VB
Think of co-evolution as a game of leap-frog…
There’s a problem when co-evolution doesn’t
exist…
The Evolution of Visual BasicThe Evolution of Visual Basic
VB1 – VB3
VB4-VB6
VB7-VB9
Windows ProgrammingMade Easy
ComponentsMade Easy
Power andSimplicity for
.NET
VB10
Continuing the trend
New VB10 FeaturesNew VB10 Features
1. Auto-Implemented Properties
2. Collection Initializers
3. Statement Lambdas
4. Covariance and Contravariance
5. Implicit Line Continuation
VB 10VB 10
Why a “Dynamic Language Runtime”?Why a “Dynamic Language Runtime”?
Common Language Runtime
Statically-Typed
C#VB
RubyPython
Dynamically-Typed
Why a “Dynamic Language Runtime”?Why a “Dynamic Language Runtime”?
Common Language Runtime
Statically-Typed
C#VB
RubyPython
Dynamically-Typed
Dynamic Language Runtime
PythonBinder
RubyBinder
COMBinder
JScriptBinder
ObjectBinder
.NET Dynamic Programming.NET Dynamic Programming
Dynamic Language Runtime
Expression TreesDynamic Dispatch
Call Site Caching
IronPython
IronRuby C# VB.NET Others…
Dynamically Typed ObjectsDynamically Typed Objects
Calculator calc = GetCalculator();int sum = calc.Add(10, 20);
object calc = GetCalculator();Type calcType = calc.GetType();object res = calcType.InvokeMember("Add", BindingFlags.InvokeMethod, null, new object[] { 10, 20 });int sum = Convert.ToInt32(res);
ScriptObject calc = GetCalculator();object res = calc.Invoke("Add", 10, 20);int sum = Convert.ToInt32(res);
dynamic calc = GetCalculator();int sum = calc.Add(10, 20);
Statically typed to be
dynamic
Dynamic method
invocation
Dynamic conversion
Dynamic Language InteropDynamic Language Interop
Summary…Summary…
1. Targeting the current trends in programming languages
2. Addressing current pain points in developing for Windows and the .NET Framework
3. Laying the foundation to enable developers to solve tomorrow’s problems