160 likes | 249 Views
.NET 3.5 – Mysteries. NetFx Evolution. NetFx 3.5 Feature List. Automatic Properties Object and Collection Initializers Extension Methods Lambda Expressions Implicit Typing Anonymous Method/Types Partial Methods LINQ. Automatic Properties. Two-in-one. Clean, Compact and Concise.
E N D
NetFx 3.5 Feature List • Automatic Properties • Object and Collection Initializers • Extension Methods • Lambda Expressions • Implicit Typing • Anonymous Method/Types • Partial Methods • LINQ
Automatic Properties • Two-in-one. • Clean, Compact and Concise. • Makes Visual Basic programmers jealous . • Speed, speed, speed! public class Person { public string FirstName { get; set; } } public class Person { private string _firstName; public string FirstName { get { return _firstName; } set { _firstName = value; } }
Object and Collection Initializers • Did you C this? • What’s the best one-liner of .Net? • Object and Collection Initializers. • Named assignments. • Isn’t intelliSense just wonderful? • A little helping hand. Personperson = new Person(); person.FirstName = "Scott"; person.LastName = "Guthrie“; person.Age = 32; great "syntactic sugar" language feature called "object Initializers" that allows you to-do this and re-write the above code like so: Personperson = new Person { FirstName="Scott", LastName="Guthrie", Age=32 };
Extension Methods • Static Implementation. • Scoped in namespace. • Limited access and Low priority. • Fuel for the LINQ Engine. string email = Request.QueryString["email"];if ( email.IsValidEmailAddress() ) {}
Lambda Expressions • The next step… • Concise and not that complex. • Just like anonymous method, but smaller. • Can be converted to a Expression Tree. • Why do we need it?
Implicit Typing • It’s implicit, not dynamic. • Specific rules to follow. • Helps with LINQ • Helps with Generic Extension Methods • Helps with Lambda Expressions
Anonymous Methods • create inline un-named methods in your code int[] EvenInts = Array.FindAll (Ints, delegate(intints) { return (ints % 2 == 0); } );
Anonymous Types • allow you to create a class structure on the fly. var dog = new { Breed = "Cocker Spaniel", Coat = "black", FerocityLevel = 1 };
Partial Methods • Its also not a method defined in two files. • So, what is a partial method after all? • A separation of declaration and definition. • What, how can it disappear? • Why do we need it? partial class PartialMethods //Part 1{ static void Main() { Do(); } static partial void Do();} partial class PartialMethods //Part 2{ static partial void Do() {}}
LINQ The Mysterious LINQ
LINQ • So, what is LINQ(Language-INtegratedQuery)? • It extends C# and Visual Basic with native language syntax for queries and provides class libraries to take advantage of these capabilities. • LINQ to SQL. • LINQ to Objects. • LINQ to XML. • How does it work?
Summary • Did we miss the Foundations? • What about Service Pack 1? • WPF improvements • .NET Framework 3.5 SP1 Optimized Client Runtime • New ADO.NET Data Features • ADO.NET Entity Framework • ADO.NET Data Services • New ASP.NET Features • ASP.NET Dynamic Data • Improved ASP.NET AJX Support • Why 3.5 when 4 is already out? • Can I use Visual Studio 2010 with 3.5? • Yes, because of multi-targeting feature