SlideShare une entreprise Scribd logo
1  sur  18
What's New in C# 3.0?  Clint Edmonson Architect Evangelist Microsoft Corporation www.notsotrivial.net
Agenda ,[object Object],[object Object],[object Object],[object Object],[object Object]
C# 3.0 - Design Themes Improves on C# 2.0 100% Backwards Compatible Language Integrated Query (LINQ)
New Features in Action
New Features in C# 3.0  Local Variable Type Inference Object Initializers Collection Initializers Anonymous Types Auto-Implemented Properties Extension Methods Lambdas Query Expressions LINQ Partial Methods
Local Variable Type Inference private static void LocalVariableTypeInference() { // Using the new 'var' keyword you can declare variables without having  // to explicity declare their type. At compile time, the compiler determines  // the type based on the assignment. int x = 10; var y = x; // Since the type inference happens at compile time, you cannot declare  // a 'var' without an assignment //var a; // Output the type name for y Console.WriteLine( y.GetType().ToString() ); }
Object Initializers private static void ObjectInitializers() { // Simplest way to create an object and set it's properties var employee1 = new Employee(); employee1.ID = 1; employee1.FirstName = "Bill"; employee1.LastName = "Gates"; Console.WriteLine( employee1.ToString() ); // We can always add a parameterized constructor to simplify coding var employee2 = new Employee( 2, "Steve", "Balmer" ); Console.WriteLine( employee2.ToString() ); // New way to create object, providing all the property value assignments // Works with any publicly accessible properties and fields var employee3 = new Employee() { ID=3, FirstName="Clint", LastName="Edmonson" }; Console.WriteLine( employee3.ToString() ); }
Collection Initializers private static void CollectionInitializers() { // Create a prepopulated list var employeeList = new List<Employee>  { new Employee { ID=1, FirstName=&quot;Bill&quot;,  LastName=&quot;Gates&quot;  }, new Employee { ID=2, FirstName=&quot;Steve&quot;, LastName=&quot;Balmer&quot;  }, new Employee { ID=3, FirstName=&quot;Clint&quot;, LastName=&quot;Edmonson&quot; } }; // Loop through and display contents of list foreach( var employee in employeeList ) { Console.WriteLine( employee.ToString() ); } }
Anonymous Types private static void AnonymousTypes() { var a = new { Name = &quot;A&quot;, Price = 3 }; Console.WriteLine( a.GetType().ToString() ); Console.WriteLine( &quot;Name = {0} : Price = {1}&quot;, a.Name, a.Price ); }
Auto-Implemented Properties public class Employee { public int ID { get; set; } public string FirstName { get; set; } public string LastName { get; set; } }
Extension Methods public static class StringExtensionMethods { // NOTE: When using an extension method to extend a type whose source  // code you cannot change, you run the risk that a change in the implementation // of the type will cause your extension method to break. // // If you do implement extension methods for a given type, remember the following  // two points: // - An extension method will never be called if it has the same signature  //  as a method defined in the type. // - Extension methods are brought into scope at the namespace level. For example, //  if you have multiple static classes that contain extension methods in a single  //  namespace named Extensions, they will all be brought into scope by the using  //  Extensions; namespace. // public static int WordCount( this String str ) { return str.Split( new char[] { ' ', '.', '?' },    StringSplitOptions.RemoveEmptyEntries ).Length; } } // Usage string s = &quot;Hello Extension Methods&quot;; int i = s.WordCount();
Partial Methods // Employee.cs public partial class Employee { public bool Terminated { get { return this.terminated; } set { this.terminated = value; this.OnTerminated(); } } private bool terminated; } // Employee.Customization.cs public partial class Employee { // If this method is not implemented // compiler will ignore calls to it partial void OnTerminated() { // Clear the employee's ID number this.ID = 0; } }
LINQ Expressions private static void LinqExpressions() { // Create a list of employees var employeeList = new List<Employee>  { new Employee { ID=1, FirstName=&quot;Bill&quot;,  LastName=&quot;Gates&quot;  }, new Employee { ID=2, FirstName=&quot;Steve&quot;, LastName=&quot;Balmer&quot;  }, new Employee { ID=3, FirstName=&quot;Clint&quot;, LastName=&quot;Edmonson&quot; } }; // Search the list for founders using a lambda expression var foudersByLambda = employeeList.FindAll(  employee => (employee.ID == 1 || employee.ID == 2) ); Console.WriteLine( foudersByLambda.Count.ToString() ); // Display collection using a lambda expression foudersByLambda.ForEach( employee => Console.WriteLine( employee.ToString() ) ); }
Query Expressions & Expression Trees private static void QueriesAndExpressions() { // Create a list of employees var employeeList = new List<Employee>  { new Employee { ID=1, FirstName=&quot;Bill&quot;,  LastName=&quot;Gates&quot;  }, new Employee { ID=2, FirstName=&quot;Steve&quot;, LastName=&quot;Balmer&quot;  }, new Employee { ID=3, FirstName=&quot;Clint&quot;, LastName=&quot;Edmonson&quot; } }; // Retrieve the founders via a LINQ query var query1 = from  employee in employeeList   where  employee.ID == 1 || employee.ID == 2   select employee; var founders = query1.ToList<Employee>(); founders.ForEach( founder => Console.WriteLine( founder.ToString() ) ); // Retrieve the new hires via a LINQ query that returns an anonymous type var query2 = from employee in employeeList   where employee.ID == 3   select new   { employee.FirstName, employee.LastName   }; var newHires = query2.ToList(); newHires.ForEach( newHire => Console.WriteLine( newHire.ToString() ) ); }
Best Practices ,[object Object],[object Object],[object Object],[object Object]
For More Information… ,[object Object],[object Object],[object Object],[object Object]
Questions and Answers ,[object Object],[object Object],[object Object],[object Object]
 

Contenu connexe

Tendances

The Ring programming language version 1.5.2 book - Part 79 of 181
The Ring programming language version 1.5.2 book - Part 79 of 181The Ring programming language version 1.5.2 book - Part 79 of 181
The Ring programming language version 1.5.2 book - Part 79 of 181Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 59 of 84
The Ring programming language version 1.2 book - Part 59 of 84The Ring programming language version 1.2 book - Part 59 of 84
The Ring programming language version 1.2 book - Part 59 of 84Mahmoud Samir Fayed
 
The Ring programming language version 1.3 book - Part 62 of 88
The Ring programming language version 1.3 book - Part 62 of 88The Ring programming language version 1.3 book - Part 62 of 88
The Ring programming language version 1.3 book - Part 62 of 88Mahmoud Samir Fayed
 
Swift Programming Language
Swift Programming LanguageSwift Programming Language
Swift Programming LanguageGiuseppe Arici
 
Denis Lebedev, Swift
Denis  Lebedev, SwiftDenis  Lebedev, Swift
Denis Lebedev, SwiftYandex
 
Introduction to Swift programming language.
Introduction to Swift programming language.Introduction to Swift programming language.
Introduction to Swift programming language.Icalia Labs
 
Lecture 3, c++(complete reference,herbet sheidt)chapter-13
Lecture 3, c++(complete reference,herbet sheidt)chapter-13Lecture 3, c++(complete reference,herbet sheidt)chapter-13
Lecture 3, c++(complete reference,herbet sheidt)chapter-13Abu Saleh
 
C# Variables and Operators
C# Variables and OperatorsC# Variables and Operators
C# Variables and OperatorsSunil OS
 
C++ Course - Lesson 3
C++ Course - Lesson 3C++ Course - Lesson 3
C++ Course - Lesson 3Mohamed Ahmed
 
Cocoa Design Patterns in Swift
Cocoa Design Patterns in SwiftCocoa Design Patterns in Swift
Cocoa Design Patterns in SwiftMichele Titolo
 
The Swift Compiler and Standard Library
The Swift Compiler and Standard LibraryThe Swift Compiler and Standard Library
The Swift Compiler and Standard LibrarySantosh Rajan
 
Let's build a parser!
Let's build a parser!Let's build a parser!
Let's build a parser!Boy Baukema
 

Tendances (20)

C#.net evolution part 2
C#.net evolution part 2C#.net evolution part 2
C#.net evolution part 2
 
The Ring programming language version 1.5.2 book - Part 79 of 181
The Ring programming language version 1.5.2 book - Part 79 of 181The Ring programming language version 1.5.2 book - Part 79 of 181
The Ring programming language version 1.5.2 book - Part 79 of 181
 
C#.net Evolution part 1
C#.net Evolution part 1C#.net Evolution part 1
C#.net Evolution part 1
 
The Ring programming language version 1.2 book - Part 59 of 84
The Ring programming language version 1.2 book - Part 59 of 84The Ring programming language version 1.2 book - Part 59 of 84
The Ring programming language version 1.2 book - Part 59 of 84
 
The Ring programming language version 1.3 book - Part 62 of 88
The Ring programming language version 1.3 book - Part 62 of 88The Ring programming language version 1.3 book - Part 62 of 88
The Ring programming language version 1.3 book - Part 62 of 88
 
Swift Programming Language
Swift Programming LanguageSwift Programming Language
Swift Programming Language
 
Design Patterns in Ruby
Design Patterns in RubyDesign Patterns in Ruby
Design Patterns in Ruby
 
Denis Lebedev, Swift
Denis  Lebedev, SwiftDenis  Lebedev, Swift
Denis Lebedev, Swift
 
Introduction to Swift programming language.
Introduction to Swift programming language.Introduction to Swift programming language.
Introduction to Swift programming language.
 
Lecture 3, c++(complete reference,herbet sheidt)chapter-13
Lecture 3, c++(complete reference,herbet sheidt)chapter-13Lecture 3, c++(complete reference,herbet sheidt)chapter-13
Lecture 3, c++(complete reference,herbet sheidt)chapter-13
 
C# Variables and Operators
C# Variables and OperatorsC# Variables and Operators
C# Variables and Operators
 
DIG1108 Lesson 6
DIG1108 Lesson 6DIG1108 Lesson 6
DIG1108 Lesson 6
 
C++ Course - Lesson 3
C++ Course - Lesson 3C++ Course - Lesson 3
C++ Course - Lesson 3
 
Class
ClassClass
Class
 
Developing iOS apps with Swift
Developing iOS apps with SwiftDeveloping iOS apps with Swift
Developing iOS apps with Swift
 
Ch7 C++
Ch7 C++Ch7 C++
Ch7 C++
 
Cocoa Design Patterns in Swift
Cocoa Design Patterns in SwiftCocoa Design Patterns in Swift
Cocoa Design Patterns in Swift
 
The Swift Compiler and Standard Library
The Swift Compiler and Standard LibraryThe Swift Compiler and Standard Library
The Swift Compiler and Standard Library
 
Quick swift tour
Quick swift tourQuick swift tour
Quick swift tour
 
Let's build a parser!
Let's build a parser!Let's build a parser!
Let's build a parser!
 

En vedette

Csharp4 arrays and_tuples
Csharp4 arrays and_tuplesCsharp4 arrays and_tuples
Csharp4 arrays and_tuplesAbed Bukhari
 
Csharp4 delegates lambda_and_events
Csharp4 delegates lambda_and_eventsCsharp4 delegates lambda_and_events
Csharp4 delegates lambda_and_eventsAbed Bukhari
 
Secure mvc application saineshwar
Secure mvc application   saineshwarSecure mvc application   saineshwar
Secure mvc application saineshwarSaineshwar bageri
 
Free MVC project to learn for beginners.
Free MVC project to learn for beginners.Free MVC project to learn for beginners.
Free MVC project to learn for beginners.Saineshwar bageri
 
Introduction to .NET Core & ASP.NET Core MVC
Introduction to .NET Core & ASP.NET Core MVCIntroduction to .NET Core & ASP.NET Core MVC
Introduction to .NET Core & ASP.NET Core MVCSaineshwar bageri
 
Introduction to C# 6.0 and 7.0
Introduction to C# 6.0 and 7.0Introduction to C# 6.0 and 7.0
Introduction to C# 6.0 and 7.0Saineshwar bageri
 

En vedette (9)

Csharp4 arrays and_tuples
Csharp4 arrays and_tuplesCsharp4 arrays and_tuples
Csharp4 arrays and_tuples
 
Csharp4 delegates lambda_and_events
Csharp4 delegates lambda_and_eventsCsharp4 delegates lambda_and_events
Csharp4 delegates lambda_and_events
 
Secure mvc application saineshwar
Secure mvc application   saineshwarSecure mvc application   saineshwar
Secure mvc application saineshwar
 
C# language
C# languageC# language
C# language
 
Free MVC project to learn for beginners.
Free MVC project to learn for beginners.Free MVC project to learn for beginners.
Free MVC project to learn for beginners.
 
Csharp4 basics
Csharp4 basicsCsharp4 basics
Csharp4 basics
 
C# 3.5 Features
C# 3.5 FeaturesC# 3.5 Features
C# 3.5 Features
 
Introduction to .NET Core & ASP.NET Core MVC
Introduction to .NET Core & ASP.NET Core MVCIntroduction to .NET Core & ASP.NET Core MVC
Introduction to .NET Core & ASP.NET Core MVC
 
Introduction to C# 6.0 and 7.0
Introduction to C# 6.0 and 7.0Introduction to C# 6.0 and 7.0
Introduction to C# 6.0 and 7.0
 

Similaire à Whats New In C# 3.0

Create a C# applicationYou are to create a class object called “Em.pdf
Create a C# applicationYou are to create a class object called “Em.pdfCreate a C# applicationYou are to create a class object called “Em.pdf
Create a C# applicationYou are to create a class object called “Em.pdffeelingspaldi
 
Embedded Typesafe Domain Specific Languages for Java
Embedded Typesafe Domain Specific Languages for JavaEmbedded Typesafe Domain Specific Languages for Java
Embedded Typesafe Domain Specific Languages for JavaJevgeni Kabanov
 
Chapter 8 Inheritance
Chapter 8 InheritanceChapter 8 Inheritance
Chapter 8 InheritanceAmrit Kaur
 
Library Website
Library WebsiteLibrary Website
Library Websitegholtron
 
Clean code _v2003
 Clean code _v2003 Clean code _v2003
Clean code _v2003R696
 
Templates exception handling
Templates exception handlingTemplates exception handling
Templates exception handlingsanya6900
 
For C# need to make these changes to this programm, httppastebin..pdf
For C# need to make these changes to this programm, httppastebin..pdfFor C# need to make these changes to this programm, httppastebin..pdf
For C# need to make these changes to this programm, httppastebin..pdffathimafancyjeweller
 
I am trying to change this code from STRUCTS to CLASSES, the members.pdf
I am trying to change this code from STRUCTS to CLASSES, the members.pdfI am trying to change this code from STRUCTS to CLASSES, the members.pdf
I am trying to change this code from STRUCTS to CLASSES, the members.pdfpetercoiffeur18
 
Micro-ORM Introduction - Don't overcomplicate
Micro-ORM Introduction - Don't overcomplicateMicro-ORM Introduction - Don't overcomplicate
Micro-ORM Introduction - Don't overcomplicateKiev ALT.NET
 
2. Create a Java class called EmployeeMain within the same project Pr.docx
 2. Create a Java class called EmployeeMain within the same project Pr.docx 2. Create a Java class called EmployeeMain within the same project Pr.docx
2. Create a Java class called EmployeeMain within the same project Pr.docxajoy21
 
how do i expand upon selectionSortType so that you are no longer bou.pdf
how do i expand upon selectionSortType so that you are no longer bou.pdfhow do i expand upon selectionSortType so that you are no longer bou.pdf
how do i expand upon selectionSortType so that you are no longer bou.pdffootwearpark
 
Library Project Phase 1
Library Project Phase 1Library Project Phase 1
Library Project Phase 1gholtron
 
Gift-VT Tools Development Overview
Gift-VT Tools Development OverviewGift-VT Tools Development Overview
Gift-VT Tools Development Overviewstn_tkiller
 
Use the code below from the previous assignment that we need to exte.pdf
Use the code below from the previous assignment that we need to exte.pdfUse the code below from the previous assignment that we need to exte.pdf
Use the code below from the previous assignment that we need to exte.pdfsales87
 
maincpp Build and procees a sorted linked list of Patie.pdf
maincpp   Build and procees a sorted linked list of Patie.pdfmaincpp   Build and procees a sorted linked list of Patie.pdf
maincpp Build and procees a sorted linked list of Patie.pdfadityastores21
 

Similaire à Whats New In C# 3.0 (20)

PostThis
PostThisPostThis
PostThis
 
Create a C# applicationYou are to create a class object called “Em.pdf
Create a C# applicationYou are to create a class object called “Em.pdfCreate a C# applicationYou are to create a class object called “Em.pdf
Create a C# applicationYou are to create a class object called “Em.pdf
 
Embedded Typesafe Domain Specific Languages for Java
Embedded Typesafe Domain Specific Languages for JavaEmbedded Typesafe Domain Specific Languages for Java
Embedded Typesafe Domain Specific Languages for Java
 
Chapter 8 Inheritance
Chapter 8 InheritanceChapter 8 Inheritance
Chapter 8 Inheritance
 
Library Website
Library WebsiteLibrary Website
Library Website
 
Linq intro
Linq introLinq intro
Linq intro
 
Clean code _v2003
 Clean code _v2003 Clean code _v2003
Clean code _v2003
 
Lecture5
Lecture5Lecture5
Lecture5
 
Templates exception handling
Templates exception handlingTemplates exception handling
Templates exception handling
 
For C# need to make these changes to this programm, httppastebin..pdf
For C# need to make these changes to this programm, httppastebin..pdfFor C# need to make these changes to this programm, httppastebin..pdf
For C# need to make these changes to this programm, httppastebin..pdf
 
I am trying to change this code from STRUCTS to CLASSES, the members.pdf
I am trying to change this code from STRUCTS to CLASSES, the members.pdfI am trying to change this code from STRUCTS to CLASSES, the members.pdf
I am trying to change this code from STRUCTS to CLASSES, the members.pdf
 
Classes
ClassesClasses
Classes
 
Micro-ORM Introduction - Don't overcomplicate
Micro-ORM Introduction - Don't overcomplicateMicro-ORM Introduction - Don't overcomplicate
Micro-ORM Introduction - Don't overcomplicate
 
2. Create a Java class called EmployeeMain within the same project Pr.docx
 2. Create a Java class called EmployeeMain within the same project Pr.docx 2. Create a Java class called EmployeeMain within the same project Pr.docx
2. Create a Java class called EmployeeMain within the same project Pr.docx
 
how do i expand upon selectionSortType so that you are no longer bou.pdf
how do i expand upon selectionSortType so that you are no longer bou.pdfhow do i expand upon selectionSortType so that you are no longer bou.pdf
how do i expand upon selectionSortType so that you are no longer bou.pdf
 
Library Project Phase 1
Library Project Phase 1Library Project Phase 1
Library Project Phase 1
 
Gift-VT Tools Development Overview
Gift-VT Tools Development OverviewGift-VT Tools Development Overview
Gift-VT Tools Development Overview
 
Use the code below from the previous assignment that we need to exte.pdf
Use the code below from the previous assignment that we need to exte.pdfUse the code below from the previous assignment that we need to exte.pdf
Use the code below from the previous assignment that we need to exte.pdf
 
maincpp Build and procees a sorted linked list of Patie.pdf
maincpp   Build and procees a sorted linked list of Patie.pdfmaincpp   Build and procees a sorted linked list of Patie.pdf
maincpp Build and procees a sorted linked list of Patie.pdf
 
C++lecture9
C++lecture9C++lecture9
C++lecture9
 

Plus de Clint Edmonson

New Product Concept Design.pptx
New Product Concept Design.pptxNew Product Concept Design.pptx
New Product Concept Design.pptxClint Edmonson
 
Lean & Agile Essentials
Lean & Agile EssentialsLean & Agile Essentials
Lean & Agile EssentialsClint Edmonson
 
MICROSOFT BLAZOR - NEXT GENERATION WEB UI OR SILVERLIGHT ALL OVER AGAIN?
MICROSOFT BLAZOR - NEXT GENERATION WEB UI OR SILVERLIGHT ALL OVER AGAIN?MICROSOFT BLAZOR - NEXT GENERATION WEB UI OR SILVERLIGHT ALL OVER AGAIN?
MICROSOFT BLAZOR - NEXT GENERATION WEB UI OR SILVERLIGHT ALL OVER AGAIN?Clint Edmonson
 
Flow, the Universe and Everything
Flow, the Universe and EverythingFlow, the Universe and Everything
Flow, the Universe and EverythingClint Edmonson
 
Application architecture jumpstart
Application architecture jumpstartApplication architecture jumpstart
Application architecture jumpstartClint Edmonson
 
Code smells and Other Malodorous Software Odors
Code smells and Other Malodorous Software OdorsCode smells and Other Malodorous Software Odors
Code smells and Other Malodorous Software OdorsClint Edmonson
 
Lean & Agile DevOps with VSTS and TFS 2015
Lean & Agile DevOps with VSTS and TFS 2015Lean & Agile DevOps with VSTS and TFS 2015
Lean & Agile DevOps with VSTS and TFS 2015Clint Edmonson
 
Application Architecture Jumpstart
Application Architecture JumpstartApplication Architecture Jumpstart
Application Architecture JumpstartClint Edmonson
 
Agile Metrics That Matter
Agile Metrics That MatterAgile Metrics That Matter
Agile Metrics That MatterClint Edmonson
 
Advanced oop laws, principles, idioms
Advanced oop laws, principles, idiomsAdvanced oop laws, principles, idioms
Advanced oop laws, principles, idiomsClint Edmonson
 
Application architecture jumpstart
Application architecture jumpstartApplication architecture jumpstart
Application architecture jumpstartClint Edmonson
 
ADO.NET Entity Framework
ADO.NET Entity FrameworkADO.NET Entity Framework
ADO.NET Entity FrameworkClint Edmonson
 
Windows 8 - The JavaScript Story
Windows 8 - The JavaScript StoryWindows 8 - The JavaScript Story
Windows 8 - The JavaScript StoryClint Edmonson
 
Windows Azure Jumpstart
Windows Azure JumpstartWindows Azure Jumpstart
Windows Azure JumpstartClint Edmonson
 
Introduction to Windows Azure Virtual Machines
Introduction to Windows Azure Virtual MachinesIntroduction to Windows Azure Virtual Machines
Introduction to Windows Azure Virtual MachinesClint Edmonson
 
Peering through the Clouds - Cloud Architectures You Need to Master
Peering through the Clouds - Cloud Architectures You Need to MasterPeering through the Clouds - Cloud Architectures You Need to Master
Peering through the Clouds - Cloud Architectures You Need to MasterClint Edmonson
 
Architecting Scalable Applications in the Cloud
Architecting Scalable Applications in the CloudArchitecting Scalable Applications in the Cloud
Architecting Scalable Applications in the CloudClint Edmonson
 
Windows Azure jumpstart
Windows Azure jumpstartWindows Azure jumpstart
Windows Azure jumpstartClint Edmonson
 
Windows Azure Virtual Machines
Windows Azure Virtual MachinesWindows Azure Virtual Machines
Windows Azure Virtual MachinesClint Edmonson
 

Plus de Clint Edmonson (20)

New Product Concept Design.pptx
New Product Concept Design.pptxNew Product Concept Design.pptx
New Product Concept Design.pptx
 
Lean & Agile Essentials
Lean & Agile EssentialsLean & Agile Essentials
Lean & Agile Essentials
 
MICROSOFT BLAZOR - NEXT GENERATION WEB UI OR SILVERLIGHT ALL OVER AGAIN?
MICROSOFT BLAZOR - NEXT GENERATION WEB UI OR SILVERLIGHT ALL OVER AGAIN?MICROSOFT BLAZOR - NEXT GENERATION WEB UI OR SILVERLIGHT ALL OVER AGAIN?
MICROSOFT BLAZOR - NEXT GENERATION WEB UI OR SILVERLIGHT ALL OVER AGAIN?
 
Flow, the Universe and Everything
Flow, the Universe and EverythingFlow, the Universe and Everything
Flow, the Universe and Everything
 
Application architecture jumpstart
Application architecture jumpstartApplication architecture jumpstart
Application architecture jumpstart
 
Code smells and Other Malodorous Software Odors
Code smells and Other Malodorous Software OdorsCode smells and Other Malodorous Software Odors
Code smells and Other Malodorous Software Odors
 
State of agile 2016
State of agile 2016State of agile 2016
State of agile 2016
 
Lean & Agile DevOps with VSTS and TFS 2015
Lean & Agile DevOps with VSTS and TFS 2015Lean & Agile DevOps with VSTS and TFS 2015
Lean & Agile DevOps with VSTS and TFS 2015
 
Application Architecture Jumpstart
Application Architecture JumpstartApplication Architecture Jumpstart
Application Architecture Jumpstart
 
Agile Metrics That Matter
Agile Metrics That MatterAgile Metrics That Matter
Agile Metrics That Matter
 
Advanced oop laws, principles, idioms
Advanced oop laws, principles, idiomsAdvanced oop laws, principles, idioms
Advanced oop laws, principles, idioms
 
Application architecture jumpstart
Application architecture jumpstartApplication architecture jumpstart
Application architecture jumpstart
 
ADO.NET Entity Framework
ADO.NET Entity FrameworkADO.NET Entity Framework
ADO.NET Entity Framework
 
Windows 8 - The JavaScript Story
Windows 8 - The JavaScript StoryWindows 8 - The JavaScript Story
Windows 8 - The JavaScript Story
 
Windows Azure Jumpstart
Windows Azure JumpstartWindows Azure Jumpstart
Windows Azure Jumpstart
 
Introduction to Windows Azure Virtual Machines
Introduction to Windows Azure Virtual MachinesIntroduction to Windows Azure Virtual Machines
Introduction to Windows Azure Virtual Machines
 
Peering through the Clouds - Cloud Architectures You Need to Master
Peering through the Clouds - Cloud Architectures You Need to MasterPeering through the Clouds - Cloud Architectures You Need to Master
Peering through the Clouds - Cloud Architectures You Need to Master
 
Architecting Scalable Applications in the Cloud
Architecting Scalable Applications in the CloudArchitecting Scalable Applications in the Cloud
Architecting Scalable Applications in the Cloud
 
Windows Azure jumpstart
Windows Azure jumpstartWindows Azure jumpstart
Windows Azure jumpstart
 
Windows Azure Virtual Machines
Windows Azure Virtual MachinesWindows Azure Virtual Machines
Windows Azure Virtual Machines
 

Dernier

Vip Udaipur Call Girls 9602870969 Dabok Airport Udaipur Escorts Service
Vip Udaipur Call Girls 9602870969 Dabok Airport Udaipur Escorts ServiceVip Udaipur Call Girls 9602870969 Dabok Airport Udaipur Escorts Service
Vip Udaipur Call Girls 9602870969 Dabok Airport Udaipur Escorts ServiceApsara Of India
 
Gripping Adult Web Series You Can't Afford to Miss
Gripping Adult Web Series You Can't Afford to MissGripping Adult Web Series You Can't Afford to Miss
Gripping Adult Web Series You Can't Afford to Missget joys
 
Call Girls In Moti Bagh (8377877756 )-Genuine Rate Girls Service
Call Girls In Moti Bagh (8377877756 )-Genuine Rate Girls ServiceCall Girls In Moti Bagh (8377877756 )-Genuine Rate Girls Service
Call Girls In Moti Bagh (8377877756 )-Genuine Rate Girls Servicedollysharma2066
 
ViP Call Girls In Udaipur 9602870969 Gulab Bagh Escorts SeRvIcE
ViP Call Girls In Udaipur 9602870969 Gulab Bagh Escorts SeRvIcEViP Call Girls In Udaipur 9602870969 Gulab Bagh Escorts SeRvIcE
ViP Call Girls In Udaipur 9602870969 Gulab Bagh Escorts SeRvIcEApsara Of India
 
Vip Delhi Ncr Call Girls Best Services Available
Vip Delhi Ncr Call Girls Best Services AvailableVip Delhi Ncr Call Girls Best Services Available
Vip Delhi Ncr Call Girls Best Services AvailableKomal Khan
 
Call Girls CG Road 7397865700 Independent Call Girls
Call Girls CG Road 7397865700  Independent Call GirlsCall Girls CG Road 7397865700  Independent Call Girls
Call Girls CG Road 7397865700 Independent Call Girlsssuser7cb4ff
 
Amil baba in Pakistan amil baba Karachi amil baba in pakistan amil baba in la...
Amil baba in Pakistan amil baba Karachi amil baba in pakistan amil baba in la...Amil baba in Pakistan amil baba Karachi amil baba in pakistan amil baba in la...
Amil baba in Pakistan amil baba Karachi amil baba in pakistan amil baba in la...Amil Baba Company
 
Taken Pilot Episode Story pitch Document
Taken Pilot Episode Story pitch DocumentTaken Pilot Episode Story pitch Document
Taken Pilot Episode Story pitch Documentf4ssvxpz62
 
原版1:1复刻卡尔加里大学毕业证UC毕业证留信学历认证
原版1:1复刻卡尔加里大学毕业证UC毕业证留信学历认证原版1:1复刻卡尔加里大学毕业证UC毕业证留信学历认证
原版1:1复刻卡尔加里大学毕业证UC毕业证留信学历认证gwhohjj
 
Amil Baba in Pakistan Kala jadu Expert Amil baba Black magic Specialist in Is...
Amil Baba in Pakistan Kala jadu Expert Amil baba Black magic Specialist in Is...Amil Baba in Pakistan Kala jadu Expert Amil baba Black magic Specialist in Is...
Amil Baba in Pakistan Kala jadu Expert Amil baba Black magic Specialist in Is...Amil Baba Company
 
Amil Baba in karachi Kala jadu Expert Amil baba Black magic Specialist in Isl...
Amil Baba in karachi Kala jadu Expert Amil baba Black magic Specialist in Isl...Amil Baba in karachi Kala jadu Expert Amil baba Black magic Specialist in Isl...
Amil Baba in karachi Kala jadu Expert Amil baba Black magic Specialist in Isl...Amil Baba Company
 
Call Girls Near The Corus Hotel New Delhi 9873777170
Call Girls Near The Corus Hotel New Delhi 9873777170Call Girls Near The Corus Hotel New Delhi 9873777170
Call Girls Near The Corus Hotel New Delhi 9873777170Sonam Pathan
 
Hi Class Call Girls In Goa 7028418221 Call Girls In Anjuna Beach Escort Services
Hi Class Call Girls In Goa 7028418221 Call Girls In Anjuna Beach Escort ServicesHi Class Call Girls In Goa 7028418221 Call Girls In Anjuna Beach Escort Services
Hi Class Call Girls In Goa 7028418221 Call Girls In Anjuna Beach Escort ServicesApsara Of India
 
Aesthetic Design Inspiration by Slidesgo.pptx
Aesthetic Design Inspiration by Slidesgo.pptxAesthetic Design Inspiration by Slidesgo.pptx
Aesthetic Design Inspiration by Slidesgo.pptxsayemalkadripial4
 
Call Girl Contact Number Andheri WhatsApp:+91-9833363713
Call Girl Contact Number Andheri WhatsApp:+91-9833363713Call Girl Contact Number Andheri WhatsApp:+91-9833363713
Call Girl Contact Number Andheri WhatsApp:+91-9833363713Sonam Pathan
 
NO1 Certified Black magic/kala jadu,manpasand shadi in lahore,karachi rawalpi...
NO1 Certified Black magic/kala jadu,manpasand shadi in lahore,karachi rawalpi...NO1 Certified Black magic/kala jadu,manpasand shadi in lahore,karachi rawalpi...
NO1 Certified Black magic/kala jadu,manpasand shadi in lahore,karachi rawalpi...Amil baba
 
GRADE 7 NEW PPT ENGLISH 1 [Autosaved].pp
GRADE 7 NEW PPT ENGLISH 1 [Autosaved].ppGRADE 7 NEW PPT ENGLISH 1 [Autosaved].pp
GRADE 7 NEW PPT ENGLISH 1 [Autosaved].ppJasmineLinogon
 
Call Girls Prahlad Nagar 9920738301 Ridhima Hire Me Full Night
Call Girls Prahlad Nagar 9920738301 Ridhima Hire Me Full NightCall Girls Prahlad Nagar 9920738301 Ridhima Hire Me Full Night
Call Girls Prahlad Nagar 9920738301 Ridhima Hire Me Full Nightssuser7cb4ff
 
North Avenue Call Girls Services, Hire Now for Full Fun
North Avenue Call Girls Services, Hire Now for Full FunNorth Avenue Call Girls Services, Hire Now for Full Fun
North Avenue Call Girls Services, Hire Now for Full FunKomal Khan
 

Dernier (20)

Vip Udaipur Call Girls 9602870969 Dabok Airport Udaipur Escorts Service
Vip Udaipur Call Girls 9602870969 Dabok Airport Udaipur Escorts ServiceVip Udaipur Call Girls 9602870969 Dabok Airport Udaipur Escorts Service
Vip Udaipur Call Girls 9602870969 Dabok Airport Udaipur Escorts Service
 
Gripping Adult Web Series You Can't Afford to Miss
Gripping Adult Web Series You Can't Afford to MissGripping Adult Web Series You Can't Afford to Miss
Gripping Adult Web Series You Can't Afford to Miss
 
Call Girls In Moti Bagh (8377877756 )-Genuine Rate Girls Service
Call Girls In Moti Bagh (8377877756 )-Genuine Rate Girls ServiceCall Girls In Moti Bagh (8377877756 )-Genuine Rate Girls Service
Call Girls In Moti Bagh (8377877756 )-Genuine Rate Girls Service
 
ViP Call Girls In Udaipur 9602870969 Gulab Bagh Escorts SeRvIcE
ViP Call Girls In Udaipur 9602870969 Gulab Bagh Escorts SeRvIcEViP Call Girls In Udaipur 9602870969 Gulab Bagh Escorts SeRvIcE
ViP Call Girls In Udaipur 9602870969 Gulab Bagh Escorts SeRvIcE
 
Vip Delhi Ncr Call Girls Best Services Available
Vip Delhi Ncr Call Girls Best Services AvailableVip Delhi Ncr Call Girls Best Services Available
Vip Delhi Ncr Call Girls Best Services Available
 
Call Girls CG Road 7397865700 Independent Call Girls
Call Girls CG Road 7397865700  Independent Call GirlsCall Girls CG Road 7397865700  Independent Call Girls
Call Girls CG Road 7397865700 Independent Call Girls
 
Amil baba in Pakistan amil baba Karachi amil baba in pakistan amil baba in la...
Amil baba in Pakistan amil baba Karachi amil baba in pakistan amil baba in la...Amil baba in Pakistan amil baba Karachi amil baba in pakistan amil baba in la...
Amil baba in Pakistan amil baba Karachi amil baba in pakistan amil baba in la...
 
Taken Pilot Episode Story pitch Document
Taken Pilot Episode Story pitch DocumentTaken Pilot Episode Story pitch Document
Taken Pilot Episode Story pitch Document
 
原版1:1复刻卡尔加里大学毕业证UC毕业证留信学历认证
原版1:1复刻卡尔加里大学毕业证UC毕业证留信学历认证原版1:1复刻卡尔加里大学毕业证UC毕业证留信学历认证
原版1:1复刻卡尔加里大学毕业证UC毕业证留信学历认证
 
Amil Baba in Pakistan Kala jadu Expert Amil baba Black magic Specialist in Is...
Amil Baba in Pakistan Kala jadu Expert Amil baba Black magic Specialist in Is...Amil Baba in Pakistan Kala jadu Expert Amil baba Black magic Specialist in Is...
Amil Baba in Pakistan Kala jadu Expert Amil baba Black magic Specialist in Is...
 
Amil Baba in karachi Kala jadu Expert Amil baba Black magic Specialist in Isl...
Amil Baba in karachi Kala jadu Expert Amil baba Black magic Specialist in Isl...Amil Baba in karachi Kala jadu Expert Amil baba Black magic Specialist in Isl...
Amil Baba in karachi Kala jadu Expert Amil baba Black magic Specialist in Isl...
 
Call Girls Near The Corus Hotel New Delhi 9873777170
Call Girls Near The Corus Hotel New Delhi 9873777170Call Girls Near The Corus Hotel New Delhi 9873777170
Call Girls Near The Corus Hotel New Delhi 9873777170
 
young call girls in Hari Nagar,🔝 9953056974 🔝 escort Service
young call girls in Hari Nagar,🔝 9953056974 🔝 escort Serviceyoung call girls in Hari Nagar,🔝 9953056974 🔝 escort Service
young call girls in Hari Nagar,🔝 9953056974 🔝 escort Service
 
Hi Class Call Girls In Goa 7028418221 Call Girls In Anjuna Beach Escort Services
Hi Class Call Girls In Goa 7028418221 Call Girls In Anjuna Beach Escort ServicesHi Class Call Girls In Goa 7028418221 Call Girls In Anjuna Beach Escort Services
Hi Class Call Girls In Goa 7028418221 Call Girls In Anjuna Beach Escort Services
 
Aesthetic Design Inspiration by Slidesgo.pptx
Aesthetic Design Inspiration by Slidesgo.pptxAesthetic Design Inspiration by Slidesgo.pptx
Aesthetic Design Inspiration by Slidesgo.pptx
 
Call Girl Contact Number Andheri WhatsApp:+91-9833363713
Call Girl Contact Number Andheri WhatsApp:+91-9833363713Call Girl Contact Number Andheri WhatsApp:+91-9833363713
Call Girl Contact Number Andheri WhatsApp:+91-9833363713
 
NO1 Certified Black magic/kala jadu,manpasand shadi in lahore,karachi rawalpi...
NO1 Certified Black magic/kala jadu,manpasand shadi in lahore,karachi rawalpi...NO1 Certified Black magic/kala jadu,manpasand shadi in lahore,karachi rawalpi...
NO1 Certified Black magic/kala jadu,manpasand shadi in lahore,karachi rawalpi...
 
GRADE 7 NEW PPT ENGLISH 1 [Autosaved].pp
GRADE 7 NEW PPT ENGLISH 1 [Autosaved].ppGRADE 7 NEW PPT ENGLISH 1 [Autosaved].pp
GRADE 7 NEW PPT ENGLISH 1 [Autosaved].pp
 
Call Girls Prahlad Nagar 9920738301 Ridhima Hire Me Full Night
Call Girls Prahlad Nagar 9920738301 Ridhima Hire Me Full NightCall Girls Prahlad Nagar 9920738301 Ridhima Hire Me Full Night
Call Girls Prahlad Nagar 9920738301 Ridhima Hire Me Full Night
 
North Avenue Call Girls Services, Hire Now for Full Fun
North Avenue Call Girls Services, Hire Now for Full FunNorth Avenue Call Girls Services, Hire Now for Full Fun
North Avenue Call Girls Services, Hire Now for Full Fun
 

Whats New In C# 3.0

  • 1. What's New in C# 3.0? Clint Edmonson Architect Evangelist Microsoft Corporation www.notsotrivial.net
  • 2.
  • 3. C# 3.0 - Design Themes Improves on C# 2.0 100% Backwards Compatible Language Integrated Query (LINQ)
  • 5. New Features in C# 3.0 Local Variable Type Inference Object Initializers Collection Initializers Anonymous Types Auto-Implemented Properties Extension Methods Lambdas Query Expressions LINQ Partial Methods
  • 6. Local Variable Type Inference private static void LocalVariableTypeInference() { // Using the new 'var' keyword you can declare variables without having // to explicity declare their type. At compile time, the compiler determines // the type based on the assignment. int x = 10; var y = x; // Since the type inference happens at compile time, you cannot declare // a 'var' without an assignment //var a; // Output the type name for y Console.WriteLine( y.GetType().ToString() ); }
  • 7. Object Initializers private static void ObjectInitializers() { // Simplest way to create an object and set it's properties var employee1 = new Employee(); employee1.ID = 1; employee1.FirstName = &quot;Bill&quot;; employee1.LastName = &quot;Gates&quot;; Console.WriteLine( employee1.ToString() ); // We can always add a parameterized constructor to simplify coding var employee2 = new Employee( 2, &quot;Steve&quot;, &quot;Balmer&quot; ); Console.WriteLine( employee2.ToString() ); // New way to create object, providing all the property value assignments // Works with any publicly accessible properties and fields var employee3 = new Employee() { ID=3, FirstName=&quot;Clint&quot;, LastName=&quot;Edmonson&quot; }; Console.WriteLine( employee3.ToString() ); }
  • 8. Collection Initializers private static void CollectionInitializers() { // Create a prepopulated list var employeeList = new List<Employee> { new Employee { ID=1, FirstName=&quot;Bill&quot;, LastName=&quot;Gates&quot; }, new Employee { ID=2, FirstName=&quot;Steve&quot;, LastName=&quot;Balmer&quot; }, new Employee { ID=3, FirstName=&quot;Clint&quot;, LastName=&quot;Edmonson&quot; } }; // Loop through and display contents of list foreach( var employee in employeeList ) { Console.WriteLine( employee.ToString() ); } }
  • 9. Anonymous Types private static void AnonymousTypes() { var a = new { Name = &quot;A&quot;, Price = 3 }; Console.WriteLine( a.GetType().ToString() ); Console.WriteLine( &quot;Name = {0} : Price = {1}&quot;, a.Name, a.Price ); }
  • 10. Auto-Implemented Properties public class Employee { public int ID { get; set; } public string FirstName { get; set; } public string LastName { get; set; } }
  • 11. Extension Methods public static class StringExtensionMethods { // NOTE: When using an extension method to extend a type whose source // code you cannot change, you run the risk that a change in the implementation // of the type will cause your extension method to break. // // If you do implement extension methods for a given type, remember the following // two points: // - An extension method will never be called if it has the same signature // as a method defined in the type. // - Extension methods are brought into scope at the namespace level. For example, // if you have multiple static classes that contain extension methods in a single // namespace named Extensions, they will all be brought into scope by the using // Extensions; namespace. // public static int WordCount( this String str ) { return str.Split( new char[] { ' ', '.', '?' }, StringSplitOptions.RemoveEmptyEntries ).Length; } } // Usage string s = &quot;Hello Extension Methods&quot;; int i = s.WordCount();
  • 12. Partial Methods // Employee.cs public partial class Employee { public bool Terminated { get { return this.terminated; } set { this.terminated = value; this.OnTerminated(); } } private bool terminated; } // Employee.Customization.cs public partial class Employee { // If this method is not implemented // compiler will ignore calls to it partial void OnTerminated() { // Clear the employee's ID number this.ID = 0; } }
  • 13. LINQ Expressions private static void LinqExpressions() { // Create a list of employees var employeeList = new List<Employee> { new Employee { ID=1, FirstName=&quot;Bill&quot;, LastName=&quot;Gates&quot; }, new Employee { ID=2, FirstName=&quot;Steve&quot;, LastName=&quot;Balmer&quot; }, new Employee { ID=3, FirstName=&quot;Clint&quot;, LastName=&quot;Edmonson&quot; } }; // Search the list for founders using a lambda expression var foudersByLambda = employeeList.FindAll( employee => (employee.ID == 1 || employee.ID == 2) ); Console.WriteLine( foudersByLambda.Count.ToString() ); // Display collection using a lambda expression foudersByLambda.ForEach( employee => Console.WriteLine( employee.ToString() ) ); }
  • 14. Query Expressions & Expression Trees private static void QueriesAndExpressions() { // Create a list of employees var employeeList = new List<Employee> { new Employee { ID=1, FirstName=&quot;Bill&quot;, LastName=&quot;Gates&quot; }, new Employee { ID=2, FirstName=&quot;Steve&quot;, LastName=&quot;Balmer&quot; }, new Employee { ID=3, FirstName=&quot;Clint&quot;, LastName=&quot;Edmonson&quot; } }; // Retrieve the founders via a LINQ query var query1 = from employee in employeeList where employee.ID == 1 || employee.ID == 2 select employee; var founders = query1.ToList<Employee>(); founders.ForEach( founder => Console.WriteLine( founder.ToString() ) ); // Retrieve the new hires via a LINQ query that returns an anonymous type var query2 = from employee in employeeList where employee.ID == 3 select new { employee.FirstName, employee.LastName }; var newHires = query2.ToList(); newHires.ForEach( newHire => Console.WriteLine( newHire.ToString() ) ); }
  • 15.
  • 16.
  • 17.
  • 18.  

Notes de l'éditeur

  1. MGB 2003 © 2003 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary. Hi, my name is Clint Edmonson Architect Evangelist based in the United States in St. Louis, Missouri. Today we’ll be talking about all the cool new language features in C# 3.0