SlideShare ist ein Scribd-Unternehmen logo
1 von 14
.Net 3.5
           -Prabhakaran
.Net 3.5 Framework
What is new in 3.5 C#?
   Implicitly Typed Local Variables
   Automatic Properties
   Object Initializer
   Collection Initializers
   Extension Methods
   Lambda Expressions
   Query Syntax
   Anonymous Types
   Expression Trees
Implicitly Typed Local Variables

Examples:
  var i = 5;
  var s = "Hello";
  var d = 1.0;
  var numbers = new int[] {1, 2, 3};
  var orders = new Dictionary<int,Order>();

Are equivalent to:
  int i = 5;
  string s = "Hello";
  double d = 1.0;
  int[] numbers = new int[] {1, 2, 3};
  Dictionary<int,Order> orders = new
  Dictionary<int,Order>();

Errors:
   var x;           // Error, no initializer to infer type from
   var y = {1, 2, 3};          // Error, collection initializer not
   permitted
   var z = null;               // Error, null type not permitted
Automatic Properties
   public class Person {

         private string _firstName;
         private string _lastName;
         private int _age;

         public string FirstName {

             get {
               return _firstName;
             }
             set {
               _firstName = value;
             }
         }

         public string LastName {

             get {
               return _lastName;
             }
             set {
               _lastName = value;
             }
         }

         public int Age {

             get {
               return _age;
             }
             set {
               _age = value; } } }
   For example, using automatic properties I can now re-write the code
    above to just be:
     public class Person {

          public string FirstName {
            get; set;
          }

          public string LastName {
            get; set;
          }

          public int Age {
            get; set;
          }
      }
   Or If I want to be really terse, I can collapse the whitespace even further
    like so:


     public class Person {
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public int Age       { get; set; }
      }
Object Initializer
 Person person = new Person();
 person.FirstName = "Scott";
 person.LastName = "Guthrie";
 person.Age = 32;


3.5
 Person person = new Person { FirstName="Scott", Last
Name="Guthrie", Age=32 };


 Person person = new Person {
    FirstName = "Scott",
    LastName = "Guthrie"
    Age = 32,
    Address = new Address {
      Street = "One Microsoft Way",
      City = "Redmond",
      State = "WA",
      Zip = 98052
    }
 };
Collection Initializers
List<Person> people = new List<Person>();

  people.Add( new Person { FirstName = "Scott", LastName = "Guthrie", A
ge = 32 } );
  people.Add( new Person { FirstName = "Bill", LastName = "Gates", Age
= 50 } );
  people.Add( new Person { FirstName = "Susanne", LastName = "Guthrie
", Age = 32 } );


3.5
List<Person> people = new List<Person> {
     new Person { FirstName = "Scott", LastName = "Guthrie", Age = 32 },
     new Person { FirstName = "Bill", LastName = "Gates", Age = 50 },
     new Person { FirstName = "Susanne", LastName = "Guthrie", Age = 3
2}
  };
Extension Methods
Extension methods allow developers to add new methods to the public contract of an
existing CLR type, without having to sub-class it or recompile the original type.

Example:
string email = Request.QueryString["email"];

if ( EmailValidator.IsValid(email) ) {

}

3.5
string email = Request.QueryString["email"];
if ( email.IsValidEmailAddress() ) {
}



public static class ScottGuExtensions
{
  public static bool IsValidEmailAddress(this string s)
  {
     Regex regex = new Regex(@"^[w-.]+@([w-]+.)+[w-]{2,4}$");
     return regex.IsMatch(s);
  }
}
Lambda Expressions
Query Syntax
   Query syntax is a convenient declarative shorthand for expressing queries
    using the standard LINQ query operators.
Anonymous Types
C# 3.5 Features

Weitere ähnliche Inhalte

Was ist angesagt?

F# Eye For The C# Guy - Seattle 2013
F# Eye For The C# Guy - Seattle 2013F# Eye For The C# Guy - Seattle 2013
F# Eye For The C# Guy - Seattle 2013Phillip Trelford
 
Powerful Analysis with the Aggregation Pipeline
Powerful Analysis with the Aggregation PipelinePowerful Analysis with the Aggregation Pipeline
Powerful Analysis with the Aggregation PipelineMongoDB
 
How To Train Your Python
How To Train Your PythonHow To Train Your Python
How To Train Your PythonJordi Riera
 
Python data structures
Python data structuresPython data structures
Python data structureskalyanibedekar
 
Building Functional Islands
Building Functional IslandsBuilding Functional Islands
Building Functional IslandsMark Jones
 
ETL for Pros: Getting Data Into MongoDB
ETL for Pros: Getting Data Into MongoDBETL for Pros: Getting Data Into MongoDB
ETL for Pros: Getting Data Into MongoDBMongoDB
 
Python chapter 2
Python chapter 2Python chapter 2
Python chapter 2Raghu nath
 
python chapter 1
python chapter 1python chapter 1
python chapter 1Raghu nath
 
First few months with Kotlin - Introduction through android examples
First few months with Kotlin - Introduction through android examplesFirst few months with Kotlin - Introduction through android examples
First few months with Kotlin - Introduction through android examplesNebojša Vukšić
 
Java: Nie popełniaj tych błędów!
Java: Nie popełniaj tych błędów!Java: Nie popełniaj tych błędów!
Java: Nie popełniaj tych błędów!Daniel Pokusa
 
ETL for Pros: Getting Data Into MongoDB
ETL for Pros: Getting Data Into MongoDBETL for Pros: Getting Data Into MongoDB
ETL for Pros: Getting Data Into MongoDBMongoDB
 
Python fundamentals - basic | WeiYuan
Python fundamentals - basic | WeiYuanPython fundamentals - basic | WeiYuan
Python fundamentals - basic | WeiYuanWei-Yuan Chang
 
The Ring programming language version 1.7 book - Part 26 of 196
The Ring programming language version 1.7 book - Part 26 of 196The Ring programming language version 1.7 book - Part 26 of 196
The Ring programming language version 1.7 book - Part 26 of 196Mahmoud Samir Fayed
 
Functional JS for everyone - 4Developers
Functional JS for everyone - 4DevelopersFunctional JS for everyone - 4Developers
Functional JS for everyone - 4DevelopersBartek Witczak
 
Getting the MVVM Kicked Out of Your F#'n Monads
Getting the MVVM Kicked Out of Your F#'n MonadsGetting the MVVM Kicked Out of Your F#'n Monads
Getting the MVVM Kicked Out of Your F#'n MonadsRichard Minerich
 
Power shell object
Power shell objectPower shell object
Power shell objectLearningTech
 

Was ist angesagt? (20)

F# Eye For The C# Guy - Seattle 2013
F# Eye For The C# Guy - Seattle 2013F# Eye For The C# Guy - Seattle 2013
F# Eye For The C# Guy - Seattle 2013
 
Powerful Analysis with the Aggregation Pipeline
Powerful Analysis with the Aggregation PipelinePowerful Analysis with the Aggregation Pipeline
Powerful Analysis with the Aggregation Pipeline
 
Templating in Go
Templating in GoTemplating in Go
Templating in Go
 
Unit vii wp ppt
Unit vii wp pptUnit vii wp ppt
Unit vii wp ppt
 
How To Train Your Python
How To Train Your PythonHow To Train Your Python
How To Train Your Python
 
Python data structures
Python data structuresPython data structures
Python data structures
 
Building Functional Islands
Building Functional IslandsBuilding Functional Islands
Building Functional Islands
 
ETL for Pros: Getting Data Into MongoDB
ETL for Pros: Getting Data Into MongoDBETL for Pros: Getting Data Into MongoDB
ETL for Pros: Getting Data Into MongoDB
 
Python chapter 2
Python chapter 2Python chapter 2
Python chapter 2
 
python chapter 1
python chapter 1python chapter 1
python chapter 1
 
First few months with Kotlin - Introduction through android examples
First few months with Kotlin - Introduction through android examplesFirst few months with Kotlin - Introduction through android examples
First few months with Kotlin - Introduction through android examples
 
Java: Nie popełniaj tych błędów!
Java: Nie popełniaj tych błędów!Java: Nie popełniaj tych błędów!
Java: Nie popełniaj tych błędów!
 
ETL for Pros: Getting Data Into MongoDB
ETL for Pros: Getting Data Into MongoDBETL for Pros: Getting Data Into MongoDB
ETL for Pros: Getting Data Into MongoDB
 
Functional es6
Functional es6Functional es6
Functional es6
 
Powershell enum
Powershell enumPowershell enum
Powershell enum
 
Python fundamentals - basic | WeiYuan
Python fundamentals - basic | WeiYuanPython fundamentals - basic | WeiYuan
Python fundamentals - basic | WeiYuan
 
The Ring programming language version 1.7 book - Part 26 of 196
The Ring programming language version 1.7 book - Part 26 of 196The Ring programming language version 1.7 book - Part 26 of 196
The Ring programming language version 1.7 book - Part 26 of 196
 
Functional JS for everyone - 4Developers
Functional JS for everyone - 4DevelopersFunctional JS for everyone - 4Developers
Functional JS for everyone - 4Developers
 
Getting the MVVM Kicked Out of Your F#'n Monads
Getting the MVVM Kicked Out of Your F#'n MonadsGetting the MVVM Kicked Out of Your F#'n Monads
Getting the MVVM Kicked Out of Your F#'n Monads
 
Power shell object
Power shell objectPower shell object
Power shell object
 

Andere mochten auch

Modelling RESTful applications – Why should I not use verbs in REST url
Modelling RESTful applications – Why should I not use verbs in REST urlModelling RESTful applications – Why should I not use verbs in REST url
Modelling RESTful applications – Why should I not use verbs in REST urlXebia IT Architects
 
Secure mvc application saineshwar
Secure mvc application   saineshwarSecure mvc application   saineshwar
Secure mvc application saineshwarSaineshwar bageri
 
Csharp4 delegates lambda_and_events
Csharp4 delegates lambda_and_eventsCsharp4 delegates lambda_and_events
Csharp4 delegates lambda_and_eventsAbed Bukhari
 
Csharp4 arrays and_tuples
Csharp4 arrays and_tuplesCsharp4 arrays and_tuples
Csharp4 arrays and_tuplesAbed Bukhari
 
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
 
Dotnet Frameworks Version History
Dotnet Frameworks Version HistoryDotnet Frameworks Version History
Dotnet Frameworks Version Historyvoltaincx
 
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
 
Visual Studio 2010 and .NET 4.0 Overview
Visual Studio 2010 and .NET 4.0 OverviewVisual Studio 2010 and .NET 4.0 Overview
Visual Studio 2010 and .NET 4.0 Overviewbwullems
 
Introduction to .NET Framework and C# (English)
Introduction to .NET Framework and C# (English)Introduction to .NET Framework and C# (English)
Introduction to .NET Framework and C# (English)Vangos Pterneas
 
.NET Framework Overview
.NET Framework Overview.NET Framework Overview
.NET Framework OverviewDoncho Minkov
 
Introduction To Dotnet
Introduction To DotnetIntroduction To Dotnet
Introduction To DotnetSAMIR BHOGAYTA
 
Introduction to .net framework
Introduction to .net frameworkIntroduction to .net framework
Introduction to .net frameworkArun Prasad
 
Architecture of .net framework
Architecture of .net frameworkArchitecture of .net framework
Architecture of .net frameworkThen Murugeshwari
 

Andere mochten auch (19)

Modelling RESTful applications – Why should I not use verbs in REST url
Modelling RESTful applications – Why should I not use verbs in REST urlModelling RESTful applications – Why should I not use verbs in REST url
Modelling RESTful applications – Why should I not use verbs in REST url
 
Secure mvc application saineshwar
Secure mvc application   saineshwarSecure mvc application   saineshwar
Secure mvc application saineshwar
 
Csharp4 delegates lambda_and_events
Csharp4 delegates lambda_and_eventsCsharp4 delegates lambda_and_events
Csharp4 delegates lambda_and_events
 
Whats New In C# 3.0
Whats New In C# 3.0Whats New In C# 3.0
Whats New In C# 3.0
 
Csharp4 arrays and_tuples
Csharp4 arrays and_tuplesCsharp4 arrays and_tuples
Csharp4 arrays and_tuples
 
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.
 
C# language
C# languageC# language
C# language
 
Csharp4 basics
Csharp4 basicsCsharp4 basics
Csharp4 basics
 
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
 
Dotnet Frameworks Version History
Dotnet Frameworks Version HistoryDotnet Frameworks Version History
Dotnet Frameworks Version History
 
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
 
Visual Studio 2010 and .NET 4.0 Overview
Visual Studio 2010 and .NET 4.0 OverviewVisual Studio 2010 and .NET 4.0 Overview
Visual Studio 2010 and .NET 4.0 Overview
 
Dotnet basics
Dotnet basicsDotnet basics
Dotnet basics
 
Introduction to .NET Framework and C# (English)
Introduction to .NET Framework and C# (English)Introduction to .NET Framework and C# (English)
Introduction to .NET Framework and C# (English)
 
Introduction to .NET Framework
Introduction to .NET FrameworkIntroduction to .NET Framework
Introduction to .NET Framework
 
.NET Framework Overview
.NET Framework Overview.NET Framework Overview
.NET Framework Overview
 
Introduction To Dotnet
Introduction To DotnetIntroduction To Dotnet
Introduction To Dotnet
 
Introduction to .net framework
Introduction to .net frameworkIntroduction to .net framework
Introduction to .net framework
 
Architecture of .net framework
Architecture of .net frameworkArchitecture of .net framework
Architecture of .net framework
 

Ähnlich wie C# 3.5 Features

Best of build 2021 - C# 10 & .NET 6
Best of build 2021 -  C# 10 & .NET 6Best of build 2021 -  C# 10 & .NET 6
Best of build 2021 - C# 10 & .NET 6Moaid Hathot
 
CodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical GroovyCodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical GroovyCodecamp Romania
 
Kotlin Data Model
Kotlin Data ModelKotlin Data Model
Kotlin Data ModelKros Huang
 
public class Person { private String name; private int age;.pdf
public class Person { private String name; private int age;.pdfpublic class Person { private String name; private int age;.pdf
public class Person { private String name; private int age;.pdfarjuncp10
 
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo....NET Conf UY
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Mar-2021_L15...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Mar-2021_L15...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Mar-2021_L15...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Mar-2021_L15...MaruMengesha
 
Simple class and object examples in java
Simple class and object examples in javaSimple class and object examples in java
Simple class and object examples in javaHarish Gyanani
 
Pitfalls In Aspect Mining
Pitfalls In Aspect MiningPitfalls In Aspect Mining
Pitfalls In Aspect Miningkim.mens
 
Scala == Effective Java
Scala == Effective JavaScala == Effective Java
Scala == Effective JavaScalac
 
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDBTDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDBtdc-globalcode
 
TypeScript by Howard
TypeScript by HowardTypeScript by Howard
TypeScript by HowardLearningTech
 
Howard type script
Howard   type scriptHoward   type script
Howard type scriptLearningTech
 
Type script by Howard
Type script by HowardType script by Howard
Type script by HowardLearningTech
 
Refactoring - Mejorando el diseño del código existente
Refactoring - Mejorando el diseño del código existenteRefactoring - Mejorando el diseño del código existente
Refactoring - Mejorando el diseño del código existenteMariano Sánchez
 
Introduction à Dart
Introduction à DartIntroduction à Dart
Introduction à DartSOAT
 
can do this in java please thanks in advance The code that y.pdf
can do this in java please thanks in advance The code that y.pdfcan do this in java please thanks in advance The code that y.pdf
can do this in java please thanks in advance The code that y.pdfakshpatil4
 
20.3 Java encapsulation
20.3 Java encapsulation20.3 Java encapsulation
20.3 Java encapsulationIntro C# Book
 
My code is not matching up with the results.The output for the cod.pdf
My code is not matching up with the results.The output for the cod.pdfMy code is not matching up with the results.The output for the cod.pdf
My code is not matching up with the results.The output for the cod.pdfsolimankellymattwe60
 

Ähnlich wie C# 3.5 Features (20)

Best of build 2021 - C# 10 & .NET 6
Best of build 2021 -  C# 10 & .NET 6Best of build 2021 -  C# 10 & .NET 6
Best of build 2021 - C# 10 & .NET 6
 
CodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical GroovyCodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical Groovy
 
Kotlin Data Model
Kotlin Data ModelKotlin Data Model
Kotlin Data Model
 
public class Person { private String name; private int age;.pdf
public class Person { private String name; private int age;.pdfpublic class Person { private String name; private int age;.pdf
public class Person { private String name; private int age;.pdf
 
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Mar-2021_L15...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Mar-2021_L15...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Mar-2021_L15...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Mar-2021_L15...
 
Simple class and object examples in java
Simple class and object examples in javaSimple class and object examples in java
Simple class and object examples in java
 
Pitfalls In Aspect Mining
Pitfalls In Aspect MiningPitfalls In Aspect Mining
Pitfalls In Aspect Mining
 
Scala == Effective Java
Scala == Effective JavaScala == Effective Java
Scala == Effective Java
 
Kotlin class
Kotlin classKotlin class
Kotlin class
 
Dev Day Andreas Roth.pdf
Dev Day Andreas Roth.pdfDev Day Andreas Roth.pdf
Dev Day Andreas Roth.pdf
 
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDBTDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
 
TypeScript by Howard
TypeScript by HowardTypeScript by Howard
TypeScript by Howard
 
Howard type script
Howard   type scriptHoward   type script
Howard type script
 
Type script by Howard
Type script by HowardType script by Howard
Type script by Howard
 
Refactoring - Mejorando el diseño del código existente
Refactoring - Mejorando el diseño del código existenteRefactoring - Mejorando el diseño del código existente
Refactoring - Mejorando el diseño del código existente
 
Introduction à Dart
Introduction à DartIntroduction à Dart
Introduction à Dart
 
can do this in java please thanks in advance The code that y.pdf
can do this in java please thanks in advance The code that y.pdfcan do this in java please thanks in advance The code that y.pdf
can do this in java please thanks in advance The code that y.pdf
 
20.3 Java encapsulation
20.3 Java encapsulation20.3 Java encapsulation
20.3 Java encapsulation
 
My code is not matching up with the results.The output for the cod.pdf
My code is not matching up with the results.The output for the cod.pdfMy code is not matching up with the results.The output for the cod.pdf
My code is not matching up with the results.The output for the cod.pdf
 

Kürzlich hochgeladen

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 

Kürzlich hochgeladen (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 

C# 3.5 Features

  • 1. .Net 3.5 -Prabhakaran
  • 3. What is new in 3.5 C#?  Implicitly Typed Local Variables  Automatic Properties  Object Initializer  Collection Initializers  Extension Methods  Lambda Expressions  Query Syntax  Anonymous Types  Expression Trees
  • 4. Implicitly Typed Local Variables Examples: var i = 5; var s = "Hello"; var d = 1.0; var numbers = new int[] {1, 2, 3}; var orders = new Dictionary<int,Order>(); Are equivalent to: int i = 5; string s = "Hello"; double d = 1.0; int[] numbers = new int[] {1, 2, 3}; Dictionary<int,Order> orders = new Dictionary<int,Order>(); Errors: var x; // Error, no initializer to infer type from var y = {1, 2, 3}; // Error, collection initializer not permitted var z = null; // Error, null type not permitted
  • 5. Automatic Properties  public class Person { private string _firstName; private string _lastName; private int _age; public string FirstName { get { return _firstName; } set { _firstName = value; } } public string LastName { get { return _lastName; } set { _lastName = value; } } public int Age { get { return _age; } set { _age = value; } } }
  • 6. For example, using automatic properties I can now re-write the code above to just be:  public class Person { public string FirstName { get; set; } public string LastName { get; set; } public int Age { get; set; } }  Or If I want to be really terse, I can collapse the whitespace even further like so:  public class Person { public string FirstName { get; set; } public string LastName { get; set; } public int Age { get; set; } }
  • 7. Object Initializer Person person = new Person(); person.FirstName = "Scott"; person.LastName = "Guthrie"; person.Age = 32; 3.5 Person person = new Person { FirstName="Scott", Last Name="Guthrie", Age=32 }; Person person = new Person { FirstName = "Scott", LastName = "Guthrie" Age = 32, Address = new Address { Street = "One Microsoft Way", City = "Redmond", State = "WA", Zip = 98052 } };
  • 8. Collection Initializers List<Person> people = new List<Person>(); people.Add( new Person { FirstName = "Scott", LastName = "Guthrie", A ge = 32 } ); people.Add( new Person { FirstName = "Bill", LastName = "Gates", Age = 50 } ); people.Add( new Person { FirstName = "Susanne", LastName = "Guthrie ", Age = 32 } ); 3.5 List<Person> people = new List<Person> { new Person { FirstName = "Scott", LastName = "Guthrie", Age = 32 }, new Person { FirstName = "Bill", LastName = "Gates", Age = 50 }, new Person { FirstName = "Susanne", LastName = "Guthrie", Age = 3 2} };
  • 9. Extension Methods Extension methods allow developers to add new methods to the public contract of an existing CLR type, without having to sub-class it or recompile the original type. Example: string email = Request.QueryString["email"]; if ( EmailValidator.IsValid(email) ) { } 3.5 string email = Request.QueryString["email"]; if ( email.IsValidEmailAddress() ) { } public static class ScottGuExtensions { public static bool IsValidEmailAddress(this string s) { Regex regex = new Regex(@"^[w-.]+@([w-]+.)+[w-]{2,4}$"); return regex.IsMatch(s); } }
  • 10.
  • 12. Query Syntax  Query syntax is a convenient declarative shorthand for expressing queries using the standard LINQ query operators.