SlideShare a Scribd company logo
Visual Studio 2008 Training

                                       3.5 RTM




Mohamed Saleh
MohamedSaleh@live.com
www.jordev.net
www.geeksconnected.com/mohamed
Module 2:
C# 3.0 Language
 Enhancements
Overview


  Automate the process of creating properties
  Enhance the objects and collections using the
  Initializers
  Create implicitly typed local variables
  Extend existing types using Extension Methods
  Write the new lambda expressions
  Using the new features in multi-framework versions
Automatically Implemented Properties
              Auto-Implemented Properties Overview

  Auto-Implemented Properties can handle the trivial
  implementation of getter and setter.
  The compiler will generate hidden backing fields with the
  implementation.
  This feature is related to the compiler and not the
  Framework Version or the Intermediate Language.
  The Auto-Implemented Properties can be implemented
  using the following syntax:
         public string Name { get; set; }
Lab 1: Using Auto-Implemented Properties


              Using the Automatic Implemented
              Properties.
              Creating read-only and write-only
              properties.
              Using Automatic Implemented Properties
              with multi-framework versions.
              Examining the effects of the Automatic
              Implemented Properties on the generated
              intermediate language.
Object and Collection Initializers
                  Object Initializer Overview

   Object Initializers allows the developer to create the
   object instance and assign the initial values at the same
   time.
   The C# 2.0 way of initializing objects:
            Customer cst2 = new Customer();
            cst2.ID = 2;
            cst2.Name = "Ayman Farouk";
            cst2.Phone = "0799-987-980-98";

   The C# 3.0 way of initializing objects:
       Customer cst3 = new Customer()
      { ID = 3, Name = "Osama Salam", Phone = "074-545-545-67" };
Object and Collection Initializers
                      Collection Initializers Overview

   The collection Initializers allows the developer to specify
   one or more elements Initializers when initializing any
   type that implements the System.Collections.Generic.IEnumerable<T>.
   Initializers Rules:
    1.   Object Initializers cannot include more than one member initializer
         for the same field or property.
    2.   The Object Initializers cannot refer to the newly created object it is
         initializing.
    3.   The Collection type must implements
         System.Collections.Generic.IEnumerable<T> in order to have
         initializers.
Lab 2: Using Initializers


                Writing Object Initializer expressions.
                Writing Collection Initializer expressions.
                Using the nested object initializer.
                Using Initializers with multi-framework
                versions.
                Examining the generated initialization
                instructions in the intermediate language.
Implicit Typing
                  Implicit Typing Overview

   The new keyword var allows the C# compiler to infers
   the type of variables
   the compiler will determines the appropriate CLR type
   Var differ than variant keyword in VB6 and COM
   Implicit Typing Context:
    1. Declaring variable at the method/property scope
    2. In a for loop statement.
    3. In a foreach loop statement.
    4. In a using statement.
Lab 3: Using Implicit Typing


               Using implicit-typed variables.
               Using implicit typing with foreach context.
               Using implicit typing with custom classes
               and lists.
               Using Implicit Typing with multi-
               framework versions.
               Examining the types of the implicit-typed
               variables.
Extension Methods
                     Extension Methods Overview

  Extension Methods allows the developer to inject new
  methods to the existing compiled types without the need
  to re-write or override the current implementations.
  Extension Methods are natively supported in the VS
  2008 IDE.
  Defining Extension Methods:
   1.   Must be defined in separated static class.
   2.   Must be declared as static methods.
   3.   The first parameter modifier of the extension methods must be this
        keyword.
Lab 4: Using Extension Methods


              Extending types with extension methods.
              Consuming extension methods.
              Extending different .NET Framework built-
              in types.
Lambda Expressions
                      Lambda Expressions Overview

  Lambda expressions allows the developer to write
  functions in expression context instead of writing it the
  regular method body with a name.
  it consists of two sides separated by the lambda
  operator => “goes to”
   the left side specifies the parameters if any, and the
  right side holds the statement block or the expression.
  Lambda Expression Limitation:
   1.   It can be only used as a part of statement.
   2.   The lambda expression does not have a name.
   3.   Lambda expression cannot contain a goto, break, or continue
        statement whose target is outside the body.
Lab 5: Writing Expression Methods


              Writing lambda expressions
              Using the Lambda expressions.
              Understanding the different in writing
              expressions using delegates, anonymous
              methods, and lambda expressions.
Review




         In this module, you learned to:
            Examine the Auto Properties Feature
            Work with Initializers
            Use the Implicit Typing Feature
            Extending Existing Types
            Writing Lambda Expressions

More Related Content

What's hot

Sqlite3 databases
Sqlite3 databasesSqlite3 databases
Sqlite3 databases
Mohamed Essam
 
Murach : HOW to work with controllers and routing
Murach : HOW to work with controllers and routingMurach : HOW to work with controllers and routing
Murach : HOW to work with controllers and routing
MahmoudOHassouna
 
ASP.Net MVC 4 [Part - 2]
ASP.Net MVC 4 [Part - 2]ASP.Net MVC 4 [Part - 2]
ASP.Net MVC 4 [Part - 2]
Mohamed Abdeen
 
MVC Training Part 1
MVC Training Part 1MVC Training Part 1
MVC Training Part 1
Lee Englestone
 
Schema-First API Design
Schema-First API DesignSchema-First API Design
Schema-First API Design
Yos Riady
 
Google closure compiler
Google closure compilerGoogle closure compiler
Google closure compiler
Prasad Kancharla
 
Rspec
RspecRspec
Angular 4 and TypeScript
Angular 4 and TypeScriptAngular 4 and TypeScript
Angular 4 and TypeScript
Ahmed El-Kady
 
Mvc by asp.net development company in india - part 2
Mvc by asp.net development company in india  - part 2Mvc by asp.net development company in india  - part 2
Mvc by asp.net development company in india - part 2
iFour Institute - Sustainable Learning
 
Monorail presentation at WebDevelopersCommunity, Feb 1, 2009
Monorail presentation at WebDevelopersCommunity, Feb 1, 2009Monorail presentation at WebDevelopersCommunity, Feb 1, 2009
Monorail presentation at WebDevelopersCommunity, Feb 1, 2009
ken.egozi
 
Monorail Introduction
Monorail IntroductionMonorail Introduction
Monorail Introduction
Andrea Magnorsky
 
Chapter 6 ppt
Chapter 6 pptChapter 6 ppt
Chapter 6 ppt
Chris Inman
 
jQuery plugins & JSON
jQuery plugins & JSONjQuery plugins & JSON
Java Custom Annotations- Part1
Java Custom Annotations- Part1Java Custom Annotations- Part1
Java Custom Annotations- Part1
Mohammad Sabir Khan
 
Part 4 Introduction to Gui with tkinter
Part 4 Introduction to Gui with tkinterPart 4 Introduction to Gui with tkinter
Part 4 Introduction to Gui with tkinter
Mohamed Essam
 
Web API with ASP.NET MVC by Software development company in india
Web API with ASP.NET  MVC  by Software development company in indiaWeb API with ASP.NET  MVC  by Software development company in india
Web API with ASP.NET MVC by Software development company in india
iFour Institute - Sustainable Learning
 
OPEN STA
OPEN STAOPEN STA
OPEN STA
Shourya Puri
 
Les14
Les14Les14
Coded ui - lesson 5 - ui map
Coded ui - lesson 5 - ui mapCoded ui - lesson 5 - ui map
Coded ui - lesson 5 - ui map
Omer Karpas
 
AngularJs Style Guide
AngularJs Style GuideAngularJs Style Guide
AngularJs Style Guide
Chiew Carol
 

What's hot (20)

Sqlite3 databases
Sqlite3 databasesSqlite3 databases
Sqlite3 databases
 
Murach : HOW to work with controllers and routing
Murach : HOW to work with controllers and routingMurach : HOW to work with controllers and routing
Murach : HOW to work with controllers and routing
 
ASP.Net MVC 4 [Part - 2]
ASP.Net MVC 4 [Part - 2]ASP.Net MVC 4 [Part - 2]
ASP.Net MVC 4 [Part - 2]
 
MVC Training Part 1
MVC Training Part 1MVC Training Part 1
MVC Training Part 1
 
Schema-First API Design
Schema-First API DesignSchema-First API Design
Schema-First API Design
 
Google closure compiler
Google closure compilerGoogle closure compiler
Google closure compiler
 
Rspec
RspecRspec
Rspec
 
Angular 4 and TypeScript
Angular 4 and TypeScriptAngular 4 and TypeScript
Angular 4 and TypeScript
 
Mvc by asp.net development company in india - part 2
Mvc by asp.net development company in india  - part 2Mvc by asp.net development company in india  - part 2
Mvc by asp.net development company in india - part 2
 
Monorail presentation at WebDevelopersCommunity, Feb 1, 2009
Monorail presentation at WebDevelopersCommunity, Feb 1, 2009Monorail presentation at WebDevelopersCommunity, Feb 1, 2009
Monorail presentation at WebDevelopersCommunity, Feb 1, 2009
 
Monorail Introduction
Monorail IntroductionMonorail Introduction
Monorail Introduction
 
Chapter 6 ppt
Chapter 6 pptChapter 6 ppt
Chapter 6 ppt
 
jQuery plugins & JSON
jQuery plugins & JSONjQuery plugins & JSON
jQuery plugins & JSON
 
Java Custom Annotations- Part1
Java Custom Annotations- Part1Java Custom Annotations- Part1
Java Custom Annotations- Part1
 
Part 4 Introduction to Gui with tkinter
Part 4 Introduction to Gui with tkinterPart 4 Introduction to Gui with tkinter
Part 4 Introduction to Gui with tkinter
 
Web API with ASP.NET MVC by Software development company in india
Web API with ASP.NET  MVC  by Software development company in indiaWeb API with ASP.NET  MVC  by Software development company in india
Web API with ASP.NET MVC by Software development company in india
 
OPEN STA
OPEN STAOPEN STA
OPEN STA
 
Les14
Les14Les14
Les14
 
Coded ui - lesson 5 - ui map
Coded ui - lesson 5 - ui mapCoded ui - lesson 5 - ui map
Coded ui - lesson 5 - ui map
 
AngularJs Style Guide
AngularJs Style GuideAngularJs Style Guide
AngularJs Style Guide
 

Similar to Module 2: C# 3.0 Language Enhancements (Slides)

Module 2: C# 3.0 Language Enhancements (Material)
Module 2: C# 3.0 Language Enhancements (Material)Module 2: C# 3.0 Language Enhancements (Material)
Module 2: C# 3.0 Language Enhancements (Material)
Mohamed Saleh
 
csharp.docx
csharp.docxcsharp.docx
csharp.docx
LenchoMamudeBaro
 
Java
JavaJava
Introduction of C++ By Pawan Thakur
Introduction of C++ By Pawan ThakurIntroduction of C++ By Pawan Thakur
Introduction of C++ By Pawan Thakur
Govt. P.G. College Dharamshala
 
ActionScript 3.0 Fundamentals
ActionScript 3.0 FundamentalsActionScript 3.0 Fundamentals
ActionScript 3.0 Fundamentals
Saurabh Narula
 
C# Unit 1 notes
C# Unit 1 notesC# Unit 1 notes
C# Unit 1 notes
Sudarshan Dhondaley
 
Templates and Exception Handling in C++
Templates and Exception Handling in C++Templates and Exception Handling in C++
Templates and Exception Handling in C++
Nimrita Koul
 
C# features
C# featuresC# features
C# features
sagaroceanic11
 
C# c# for beginners crash course master c# programming fast and easy today
C# c# for beginners crash course master c# programming fast and easy todayC# c# for beginners crash course master c# programming fast and easy today
C# c# for beginners crash course master c# programming fast and easy today
Afonso Macedo
 
Apple’s New Swift Programming Language Takes Flight With New Enhancements And...
Apple’s New Swift Programming Language Takes Flight With New Enhancements And...Apple’s New Swift Programming Language Takes Flight With New Enhancements And...
Apple’s New Swift Programming Language Takes Flight With New Enhancements And...
Azilen Technologies Pvt. Ltd.
 
Object Oriented Programming C#
Object Oriented Programming C#Object Oriented Programming C#
Object Oriented Programming C#
Muhammad Younis
 
C sharp
C sharpC sharp
C sharp
Satish Verma
 
76829060 java-coding-conventions
76829060 java-coding-conventions76829060 java-coding-conventions
76829060 java-coding-conventions
slavicp
 
Java annotations
Java annotationsJava annotations
Java annotations
FAROOK Samath
 
Perfomatix - iOS swift coding standards
Perfomatix - iOS swift coding standardsPerfomatix - iOS swift coding standards
Perfomatix - iOS swift coding standards
Perfomatix Solutions
 
Evolution of c# - by K.Jegan
Evolution of c# - by K.JeganEvolution of c# - by K.Jegan
Evolution of c# - by K.Jegan
talenttransform
 
TypeScript Overview
TypeScript OverviewTypeScript Overview
TypeScript Overview
Aniruddha Chakrabarti
 
C#ppt
C#pptC#ppt
Bca5020 visual programming
Bca5020  visual programmingBca5020  visual programming
Bca5020 visual programming
smumbahelp
 
Bca5020 visual programming
Bca5020  visual programmingBca5020  visual programming
Bca5020 visual programming
smumbahelp
 

Similar to Module 2: C# 3.0 Language Enhancements (Slides) (20)

Module 2: C# 3.0 Language Enhancements (Material)
Module 2: C# 3.0 Language Enhancements (Material)Module 2: C# 3.0 Language Enhancements (Material)
Module 2: C# 3.0 Language Enhancements (Material)
 
csharp.docx
csharp.docxcsharp.docx
csharp.docx
 
Java
JavaJava
Java
 
Introduction of C++ By Pawan Thakur
Introduction of C++ By Pawan ThakurIntroduction of C++ By Pawan Thakur
Introduction of C++ By Pawan Thakur
 
ActionScript 3.0 Fundamentals
ActionScript 3.0 FundamentalsActionScript 3.0 Fundamentals
ActionScript 3.0 Fundamentals
 
C# Unit 1 notes
C# Unit 1 notesC# Unit 1 notes
C# Unit 1 notes
 
Templates and Exception Handling in C++
Templates and Exception Handling in C++Templates and Exception Handling in C++
Templates and Exception Handling in C++
 
C# features
C# featuresC# features
C# features
 
C# c# for beginners crash course master c# programming fast and easy today
C# c# for beginners crash course master c# programming fast and easy todayC# c# for beginners crash course master c# programming fast and easy today
C# c# for beginners crash course master c# programming fast and easy today
 
Apple’s New Swift Programming Language Takes Flight With New Enhancements And...
Apple’s New Swift Programming Language Takes Flight With New Enhancements And...Apple’s New Swift Programming Language Takes Flight With New Enhancements And...
Apple’s New Swift Programming Language Takes Flight With New Enhancements And...
 
Object Oriented Programming C#
Object Oriented Programming C#Object Oriented Programming C#
Object Oriented Programming C#
 
C sharp
C sharpC sharp
C sharp
 
76829060 java-coding-conventions
76829060 java-coding-conventions76829060 java-coding-conventions
76829060 java-coding-conventions
 
Java annotations
Java annotationsJava annotations
Java annotations
 
Perfomatix - iOS swift coding standards
Perfomatix - iOS swift coding standardsPerfomatix - iOS swift coding standards
Perfomatix - iOS swift coding standards
 
Evolution of c# - by K.Jegan
Evolution of c# - by K.JeganEvolution of c# - by K.Jegan
Evolution of c# - by K.Jegan
 
TypeScript Overview
TypeScript OverviewTypeScript Overview
TypeScript Overview
 
C#ppt
C#pptC#ppt
C#ppt
 
Bca5020 visual programming
Bca5020  visual programmingBca5020  visual programming
Bca5020 visual programming
 
Bca5020 visual programming
Bca5020  visual programmingBca5020  visual programming
Bca5020 visual programming
 

Recently uploaded

Apps Break Data
Apps Break DataApps Break Data
Apps Break Data
Ivo Velitchkov
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
Javier Junquera
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota
Fwdays
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
operationspcvita
 
Dandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity serverDandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity server
Antonios Katsarakis
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
Zilliz
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
saastr
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
Edge AI and Vision Alliance
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
Jason Yip
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
Miro Wengner
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and BioinformaticiansBiomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Neo4j
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
Zilliz
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Wask
 

Recently uploaded (20)

Apps Break Data
Apps Break DataApps Break Data
Apps Break Data
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
 
Dandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity serverDandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity server
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and BioinformaticiansBiomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
 

Module 2: C# 3.0 Language Enhancements (Slides)

  • 1. Visual Studio 2008 Training 3.5 RTM Mohamed Saleh MohamedSaleh@live.com www.jordev.net www.geeksconnected.com/mohamed
  • 2. Module 2: C# 3.0 Language Enhancements
  • 3. Overview Automate the process of creating properties Enhance the objects and collections using the Initializers Create implicitly typed local variables Extend existing types using Extension Methods Write the new lambda expressions Using the new features in multi-framework versions
  • 4. Automatically Implemented Properties Auto-Implemented Properties Overview Auto-Implemented Properties can handle the trivial implementation of getter and setter. The compiler will generate hidden backing fields with the implementation. This feature is related to the compiler and not the Framework Version or the Intermediate Language. The Auto-Implemented Properties can be implemented using the following syntax: public string Name { get; set; }
  • 5. Lab 1: Using Auto-Implemented Properties Using the Automatic Implemented Properties. Creating read-only and write-only properties. Using Automatic Implemented Properties with multi-framework versions. Examining the effects of the Automatic Implemented Properties on the generated intermediate language.
  • 6. Object and Collection Initializers Object Initializer Overview Object Initializers allows the developer to create the object instance and assign the initial values at the same time. The C# 2.0 way of initializing objects: Customer cst2 = new Customer(); cst2.ID = 2; cst2.Name = "Ayman Farouk"; cst2.Phone = "0799-987-980-98"; The C# 3.0 way of initializing objects: Customer cst3 = new Customer() { ID = 3, Name = "Osama Salam", Phone = "074-545-545-67" };
  • 7. Object and Collection Initializers Collection Initializers Overview The collection Initializers allows the developer to specify one or more elements Initializers when initializing any type that implements the System.Collections.Generic.IEnumerable<T>. Initializers Rules: 1. Object Initializers cannot include more than one member initializer for the same field or property. 2. The Object Initializers cannot refer to the newly created object it is initializing. 3. The Collection type must implements System.Collections.Generic.IEnumerable<T> in order to have initializers.
  • 8. Lab 2: Using Initializers Writing Object Initializer expressions. Writing Collection Initializer expressions. Using the nested object initializer. Using Initializers with multi-framework versions. Examining the generated initialization instructions in the intermediate language.
  • 9. Implicit Typing Implicit Typing Overview The new keyword var allows the C# compiler to infers the type of variables the compiler will determines the appropriate CLR type Var differ than variant keyword in VB6 and COM Implicit Typing Context: 1. Declaring variable at the method/property scope 2. In a for loop statement. 3. In a foreach loop statement. 4. In a using statement.
  • 10. Lab 3: Using Implicit Typing Using implicit-typed variables. Using implicit typing with foreach context. Using implicit typing with custom classes and lists. Using Implicit Typing with multi- framework versions. Examining the types of the implicit-typed variables.
  • 11. Extension Methods Extension Methods Overview Extension Methods allows the developer to inject new methods to the existing compiled types without the need to re-write or override the current implementations. Extension Methods are natively supported in the VS 2008 IDE. Defining Extension Methods: 1. Must be defined in separated static class. 2. Must be declared as static methods. 3. The first parameter modifier of the extension methods must be this keyword.
  • 12. Lab 4: Using Extension Methods Extending types with extension methods. Consuming extension methods. Extending different .NET Framework built- in types.
  • 13. Lambda Expressions Lambda Expressions Overview Lambda expressions allows the developer to write functions in expression context instead of writing it the regular method body with a name. it consists of two sides separated by the lambda operator => “goes to” the left side specifies the parameters if any, and the right side holds the statement block or the expression. Lambda Expression Limitation: 1. It can be only used as a part of statement. 2. The lambda expression does not have a name. 3. Lambda expression cannot contain a goto, break, or continue statement whose target is outside the body.
  • 14. Lab 5: Writing Expression Methods Writing lambda expressions Using the Lambda expressions. Understanding the different in writing expressions using delegates, anonymous methods, and lambda expressions.
  • 15. Review In this module, you learned to: Examine the Auto Properties Feature Work with Initializers Use the Implicit Typing Feature Extending Existing Types Writing Lambda Expressions