SlideShare uma empresa Scribd logo
1 de 14
Type System
Anoop K. C.
anoop@baabte.com
www.facebook.com/anoopb
aabte
twitter.com/anoop_baabte
in.linkedin.com/in/anoopbaa
bte/
+91 9746854752
C# is a strongly-typed language. Every variable and constant has a type, as does
every expression that evaluates to a value.
The information stored in a type can include the following:
The storage space that a variable of the type requires
The maximum and minimum values that it can represent.
The members (methods, fields, events, and so on) that it contains.
The base type it inherits from.
The location where the memory for variables will be allocated at run time.
The kinds of operations that are permitted.
Example
The compiler uses type information to make sure that all operations that are
performed in your code are type safe. For example, if you declare a variable of
type int, the compiler allows you to use the variable in addition and subtraction
operations. If you try to perform those same operations on a variable of type bool,
the compiler generates an error, as shown in the following example:
When we declare a variable or constant in a program, we must either specify its
type or use the var keyword to let the compiler infer the type.
After a variable is declared, it cannot be re-declared with a new type, and it
cannot be assigned a value that is not compatible with its declared type. For
example, you cannot declare an int and then assign it a Boolean value of true.
However, values can be converted to
other types, when they are assigned
to new variables or passed as method
arguments.
A type conversion that does not cause
data loss is performed automatically
by the compiler.
A conversion that might cause data
loss requires a cast in the source code.
Built-in Types
C# provides a standard set of built-in numeric types to represent integers, floating
point values, Boolean expressions, text characters, decimal values, and other types
of data.
integers
floating point values
Boolean expressions
text characters
decimal values &
other types of data.
There are also built-in string and object types.
These are available to use in any C# program
Custom Types
We use the struct, class, interface, and enum constructs to create our own custom
types.
By default, the most frequently used types in the class library are available in any
C# program. Others become available only when we explicitly add a project
reference to the assembly in which they are defined.
After the compiler has a reference to the assembly, we can declare variables (and
constants) of the types declared in that assembly in source code.
The common type system
It is important to understand two fundamental points about the type system in
the .NET Framework:
It supports the principle of inheritance, that means, types can derive from
other types, called base types. All types derive ultimately from a single base
type, which is System.Object (C# keyword: object). This unified type hierarchy
is called the Common Type System (CTS).
Each type in the CTS is defined as either a value type or a reference type.
•Types that you define by using the struct keyword are value types
•Types that you define by using the class keyword are reference types
Reference types and value types have different compile-time rules, and different
run-time behavior.
Value types
Value type variables directly contain their values
the memory is allocated inline in whatever context the variable is declared
There is no separate heap allocation or garbage collection overhead for value-
type variables.
There are two categories of value types: struct and enum.
Value types are sealed, that means they does not allow inheritance
Reference types
A type that is defined as a class, delegate, array, or interface is a reference type.
At run time, when we declare a variable of a reference type, the variable
contains the value null until we explicitly create an instance of the object by using
the new operator, or assign it an object that has been created elsewhere by
using new
When a reference type variable is created, the memory is allocated on the
managed heap, and the variable holds only a reference to the location of the
object.
All arrays are reference types, even if their elements are value types.
Reference types fully support inheritance.
Generic types
A type which is declared with one or more type parameters that serve as a
placeholder for the actual type (the concrete type) that client code will provide
when it creates an instance of the type.
For example, the .NET Framework type System.Collections.Generic.List<T> has one
type parameter that by convention is given the name T. When you create an
instance of the type, you specify the type of the objects that the list will contain,
for example, string:
List<string> strings = new List<string>();
The use of the type parameter makes it possible to reuse the same class to hold
any type of element
Generic collection types are strongly typed
Implicit Types, Anonymous Types, and Nullable Types
We can implicitly type a local variable (but not class members) by using
the var keyword. The variable still receives a type at compile time, but the type is
provided by the compiler.
Anonymous types are types those have scope only inside the method in which
they are defined. The compiler itself will create an arbitrary class for such types,
giving us the advantage of not having to define a class for a type that is only used
inside a single method. Anonymous types are immutable.
Anonymous types provide a convenient way to encapsulate a set of read-only
properties into a single object without having to explicitly define a type first. The
type name is generated by the compiler and is not available at the source code
level. The type of each property is inferred by the compiler.
Ordinary value types cannot have a value of null. we can create nullable value
types by affixing a ? after the type. For example, int? is an int type that can also
have the value null.
Follow us @ twitter.com/baabtra
Like us @ facebook.com/baabtra
Subscribe to us @ youtube.com/baabtra
Become a follower @ slideshare.net/BaabtraMentoringPartner
Connect to us @ in.linkedin.com/in/baabtra
Thanks in advance.
www.baabtra.com | www.massbaab.com |www.baabte.com
Contact Us
Emarald Mall (Big Bazar Building)
Mavoor Road, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
NC Complex, Near Bus Stand
Mukkam, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
Cafit Square,
Hilite Business Park,
Near Pantheerankavu,
Kozhikode
Start up Village
Eranakulam,
Kerala, India.
Email: info@baabtra.com

Mais conteúdo relacionado

Mais procurados

compiler ppt on symbol table
 compiler ppt on symbol table compiler ppt on symbol table
compiler ppt on symbol table
nadarmispapaulraj
 

Mais procurados (20)

Process synchronization in Operating Systems
Process synchronization in Operating SystemsProcess synchronization in Operating Systems
Process synchronization in Operating Systems
 
Passes of compilers
Passes of compilersPasses of compilers
Passes of compilers
 
Operator Overloading
Operator OverloadingOperator Overloading
Operator Overloading
 
First and follow set
First and follow setFirst and follow set
First and follow set
 
Variable scope ppt in vb6
Variable scope ppt in vb6Variable scope ppt in vb6
Variable scope ppt in vb6
 
Type conversion
Type  conversionType  conversion
Type conversion
 
Java literals
Java literalsJava literals
Java literals
 
1.Role lexical Analyzer
1.Role lexical Analyzer1.Role lexical Analyzer
1.Role lexical Analyzer
 
compiler ppt on symbol table
 compiler ppt on symbol table compiler ppt on symbol table
compiler ppt on symbol table
 
Assembler
AssemblerAssembler
Assembler
 
Phases of Compiler
Phases of CompilerPhases of Compiler
Phases of Compiler
 
Overview of UML Diagrams
Overview of UML DiagramsOverview of UML Diagrams
Overview of UML Diagrams
 
Implicit and explicit sequence control with exception handling
Implicit and explicit sequence control with exception handlingImplicit and explicit sequence control with exception handling
Implicit and explicit sequence control with exception handling
 
Introduction to Compiler design
Introduction to Compiler design Introduction to Compiler design
Introduction to Compiler design
 
C# Common Type System & Common Language Specification
C# Common Type System & Common Language Specification C# Common Type System & Common Language Specification
C# Common Type System & Common Language Specification
 
parameter passing in c#
parameter passing in c#parameter passing in c#
parameter passing in c#
 
Network programming in java - PPT
Network programming in java - PPTNetwork programming in java - PPT
Network programming in java - PPT
 
Type casting in c programming
Type casting in c programmingType casting in c programming
Type casting in c programming
 
process creation OS
process creation OSprocess creation OS
process creation OS
 
Syntax Analysis in Compiler Design
Syntax Analysis in Compiler Design Syntax Analysis in Compiler Design
Syntax Analysis in Compiler Design
 

Destaque (7)

Presentación1
Presentación1Presentación1
Presentación1
 
презентація пирлик
презентація пирликпрезентація пирлик
презентація пирлик
 
Test Prep Presentation for NJROTC students in 2004, part 1
Test Prep Presentation for NJROTC students in 2004, part 1Test Prep Presentation for NJROTC students in 2004, part 1
Test Prep Presentation for NJROTC students in 2004, part 1
 
RUCUG: 11. Rick Dehlinger BYOC: Beware the Perimeter
RUCUG: 11. Rick Dehlinger BYOC: Beware the PerimeterRUCUG: 11. Rick Dehlinger BYOC: Beware the Perimeter
RUCUG: 11. Rick Dehlinger BYOC: Beware the Perimeter
 
Mba tiltle for 2012
Mba tiltle for 2012Mba tiltle for 2012
Mba tiltle for 2012
 
IDC 2012 MEA & Turkey Predictions
IDC 2012 MEA & Turkey PredictionsIDC 2012 MEA & Turkey Predictions
IDC 2012 MEA & Turkey Predictions
 
Webservices.nl & data quality
Webservices.nl & data qualityWebservices.nl & data quality
Webservices.nl & data quality
 

Semelhante a Type system

Introduction of C# BY Adarsh Singh
Introduction of C# BY Adarsh SinghIntroduction of C# BY Adarsh Singh
Introduction of C# BY Adarsh Singh
singhadarsh
 
ActionScript 3.0 Fundamentals
ActionScript 3.0 FundamentalsActionScript 3.0 Fundamentals
ActionScript 3.0 Fundamentals
Saurabh Narula
 

Semelhante a Type system (20)

LEARN C# PROGRAMMING WITH GMT
LEARN C# PROGRAMMING WITH GMTLEARN C# PROGRAMMING WITH GMT
LEARN C# PROGRAMMING WITH GMT
 
Typescript: Beginner to Advanced
Typescript: Beginner to AdvancedTypescript: Beginner to Advanced
Typescript: Beginner to Advanced
 
Dot net programming concept
Dot net  programming conceptDot net  programming concept
Dot net programming concept
 
A tour of C# - Overview _ Microsoft Learn.pdf
A tour of C# - Overview _ Microsoft Learn.pdfA tour of C# - Overview _ Microsoft Learn.pdf
A tour of C# - Overview _ Microsoft Learn.pdf
 
Unit 1 question and answer
Unit 1 question and answerUnit 1 question and answer
Unit 1 question and answer
 
CSharpCheatSheetV1.pdf
CSharpCheatSheetV1.pdfCSharpCheatSheetV1.pdf
CSharpCheatSheetV1.pdf
 
Data Types, Variables, and Constants in C# Programming
Data Types, Variables, and Constants in C# ProgrammingData Types, Variables, and Constants in C# Programming
Data Types, Variables, and Constants in C# Programming
 
typescript.pptx
typescript.pptxtypescript.pptx
typescript.pptx
 
Introduction of C# BY Adarsh Singh
Introduction of C# BY Adarsh SinghIntroduction of C# BY Adarsh Singh
Introduction of C# BY Adarsh Singh
 
3rd june
3rd june3rd june
3rd june
 
C# chap 4
C# chap 4C# chap 4
C# chap 4
 
C# concepts
C# conceptsC# concepts
C# concepts
 
ActionScript 3.0 Fundamentals
ActionScript 3.0 FundamentalsActionScript 3.0 Fundamentals
ActionScript 3.0 Fundamentals
 
Visual Basic User Interface -IV
Visual Basic User Interface -IVVisual Basic User Interface -IV
Visual Basic User Interface -IV
 
Objects and Types C#
Objects and Types C#Objects and Types C#
Objects and Types C#
 
Type Checking
Type CheckingType Checking
Type Checking
 
2.Getting Started with C#.Net-(C#)
2.Getting Started with C#.Net-(C#)2.Getting Started with C#.Net-(C#)
2.Getting Started with C#.Net-(C#)
 
Notes(1).pptx
Notes(1).pptxNotes(1).pptx
Notes(1).pptx
 
Chapter 2 c#
Chapter 2 c#Chapter 2 c#
Chapter 2 c#
 
TypeScript Overview
TypeScript OverviewTypeScript Overview
TypeScript Overview
 

Mais de baabtra.com - No. 1 supplier of quality freshers

Mais de baabtra.com - No. 1 supplier of quality freshers (20)

Agile methodology and scrum development
Agile methodology and scrum developmentAgile methodology and scrum development
Agile methodology and scrum development
 
Best coding practices
Best coding practicesBest coding practices
Best coding practices
 
Core java - baabtra
Core java - baabtraCore java - baabtra
Core java - baabtra
 
Acquiring new skills what you should know
Acquiring new skills   what you should knowAcquiring new skills   what you should know
Acquiring new skills what you should know
 
Baabtra.com programming at school
Baabtra.com programming at schoolBaabtra.com programming at school
Baabtra.com programming at school
 
99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love 99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love
 
Php sessions & cookies
Php sessions & cookiesPhp sessions & cookies
Php sessions & cookies
 
Php database connectivity
Php database connectivityPhp database connectivity
Php database connectivity
 
Chapter 6 database normalisation
Chapter 6  database normalisationChapter 6  database normalisation
Chapter 6 database normalisation
 
Chapter 5 transactions and dcl statements
Chapter 5  transactions and dcl statementsChapter 5  transactions and dcl statements
Chapter 5 transactions and dcl statements
 
Chapter 4 functions, views, indexing
Chapter 4  functions, views, indexingChapter 4  functions, views, indexing
Chapter 4 functions, views, indexing
 
Chapter 3 stored procedures
Chapter 3 stored proceduresChapter 3 stored procedures
Chapter 3 stored procedures
 
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
Chapter 2  grouping,scalar and aggergate functions,joins   inner join,outer joinChapter 2  grouping,scalar and aggergate functions,joins   inner join,outer join
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Microsoft holo lens
Microsoft holo lensMicrosoft holo lens
Microsoft holo lens
 
Blue brain
Blue brainBlue brain
Blue brain
 
5g
5g5g
5g
 
Aptitude skills baabtra
Aptitude skills baabtraAptitude skills baabtra
Aptitude skills baabtra
 
Gd baabtra
Gd baabtraGd baabtra
Gd baabtra
 

Último

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 

Último (20)

HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 

Type system

  • 1.
  • 2. Type System Anoop K. C. anoop@baabte.com www.facebook.com/anoopb aabte twitter.com/anoop_baabte in.linkedin.com/in/anoopbaa bte/ +91 9746854752
  • 3. C# is a strongly-typed language. Every variable and constant has a type, as does every expression that evaluates to a value. The information stored in a type can include the following: The storage space that a variable of the type requires The maximum and minimum values that it can represent. The members (methods, fields, events, and so on) that it contains. The base type it inherits from. The location where the memory for variables will be allocated at run time. The kinds of operations that are permitted.
  • 4. Example The compiler uses type information to make sure that all operations that are performed in your code are type safe. For example, if you declare a variable of type int, the compiler allows you to use the variable in addition and subtraction operations. If you try to perform those same operations on a variable of type bool, the compiler generates an error, as shown in the following example: When we declare a variable or constant in a program, we must either specify its type or use the var keyword to let the compiler infer the type.
  • 5. After a variable is declared, it cannot be re-declared with a new type, and it cannot be assigned a value that is not compatible with its declared type. For example, you cannot declare an int and then assign it a Boolean value of true. However, values can be converted to other types, when they are assigned to new variables or passed as method arguments. A type conversion that does not cause data loss is performed automatically by the compiler. A conversion that might cause data loss requires a cast in the source code.
  • 6. Built-in Types C# provides a standard set of built-in numeric types to represent integers, floating point values, Boolean expressions, text characters, decimal values, and other types of data. integers floating point values Boolean expressions text characters decimal values & other types of data. There are also built-in string and object types. These are available to use in any C# program
  • 7. Custom Types We use the struct, class, interface, and enum constructs to create our own custom types. By default, the most frequently used types in the class library are available in any C# program. Others become available only when we explicitly add a project reference to the assembly in which they are defined. After the compiler has a reference to the assembly, we can declare variables (and constants) of the types declared in that assembly in source code.
  • 8. The common type system It is important to understand two fundamental points about the type system in the .NET Framework: It supports the principle of inheritance, that means, types can derive from other types, called base types. All types derive ultimately from a single base type, which is System.Object (C# keyword: object). This unified type hierarchy is called the Common Type System (CTS). Each type in the CTS is defined as either a value type or a reference type. •Types that you define by using the struct keyword are value types •Types that you define by using the class keyword are reference types Reference types and value types have different compile-time rules, and different run-time behavior.
  • 9. Value types Value type variables directly contain their values the memory is allocated inline in whatever context the variable is declared There is no separate heap allocation or garbage collection overhead for value- type variables. There are two categories of value types: struct and enum. Value types are sealed, that means they does not allow inheritance
  • 10. Reference types A type that is defined as a class, delegate, array, or interface is a reference type. At run time, when we declare a variable of a reference type, the variable contains the value null until we explicitly create an instance of the object by using the new operator, or assign it an object that has been created elsewhere by using new When a reference type variable is created, the memory is allocated on the managed heap, and the variable holds only a reference to the location of the object. All arrays are reference types, even if their elements are value types. Reference types fully support inheritance.
  • 11. Generic types A type which is declared with one or more type parameters that serve as a placeholder for the actual type (the concrete type) that client code will provide when it creates an instance of the type. For example, the .NET Framework type System.Collections.Generic.List<T> has one type parameter that by convention is given the name T. When you create an instance of the type, you specify the type of the objects that the list will contain, for example, string: List<string> strings = new List<string>(); The use of the type parameter makes it possible to reuse the same class to hold any type of element Generic collection types are strongly typed
  • 12. Implicit Types, Anonymous Types, and Nullable Types We can implicitly type a local variable (but not class members) by using the var keyword. The variable still receives a type at compile time, but the type is provided by the compiler. Anonymous types are types those have scope only inside the method in which they are defined. The compiler itself will create an arbitrary class for such types, giving us the advantage of not having to define a class for a type that is only used inside a single method. Anonymous types are immutable. Anonymous types provide a convenient way to encapsulate a set of read-only properties into a single object without having to explicitly define a type first. The type name is generated by the compiler and is not available at the source code level. The type of each property is inferred by the compiler. Ordinary value types cannot have a value of null. we can create nullable value types by affixing a ? after the type. For example, int? is an int type that can also have the value null.
  • 13. Follow us @ twitter.com/baabtra Like us @ facebook.com/baabtra Subscribe to us @ youtube.com/baabtra Become a follower @ slideshare.net/BaabtraMentoringPartner Connect to us @ in.linkedin.com/in/baabtra Thanks in advance. www.baabtra.com | www.massbaab.com |www.baabte.com
  • 14. Contact Us Emarald Mall (Big Bazar Building) Mavoor Road, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 NC Complex, Near Bus Stand Mukkam, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 Cafit Square, Hilite Business Park, Near Pantheerankavu, Kozhikode Start up Village Eranakulam, Kerala, India. Email: info@baabtra.com