SlideShare a Scribd company logo
1 of 8
www.siri-kt.blogspot.com
C# Tutorial
Part 15 :
Reflection
www.siri-kt.blogspot.com
• Reflection objects are used for obtaining type information at
runtime. The classes that give access to the metadata of a running
program are in theSystem.Reflection namespace.
• The System.Reflection namespace contains classes that allow you
to obtain information about the application and to dynamically add
types, values, and objects to the application.
• Reflection has the following applications:
• It allows view attribute information at runtime.
• It allows examining various types in an assembly and instantiate
these types.
• It allows late binding to methods and properties
• It allows creating new types at runtime and then performs some
tasks using those types.
• Viewing Metadata
• We have mentioned in the preceding chapter that using reflection
you can view the attribute information.
• The MemberInfo object of the System.Reflection class needs to
be initialized for discovering the attributes associated with a class.
• In C#, reflection is a process to get metadata of a type at runtime.
The System.Reflection namespace contains required classes for
reflection such as:
• Type
• MemberInfo
• ConstructorInfo
• MethodInfo
• FieldInfo
• PropertyInfo
• TypeInfo
• EventInfo
• Module
• Assembly
• AssemblyName
• Pointer etc.
• The System.Reflection.Emit namespace contains classes to emit
• C# Type class
• C# Type class represents type declarations for
class types, interface types, enumeration types,
array types, value types etc. It is found in System
namespace. It inherits
System.Reflection.MemberInfo class.
Property Description
Assembly Gets the Assembly for this type.
AssemblyQualifiedName Gets the Assembly qualified name for this type.
Attributes Gets the Attributes associated with the type.
BaseType Gets the base or parent type.
FullName Gets the fully qualified name of the type.
IsAbstract is used to check if the type is Abstract.
IsArray is used to check if the type is Array.
IsClass is used to check if the type is Class.
IsEnum is used to check if the type is Enum.
IsInterface is used to check if the type is Interface.
IsNested is used to check if the type is Nested.
IsPrimitive is used to check if the type is Primitive.
IsPointer is used to check if the type is Pointer.
IsNotPublic is used to check if the type is not Public.
IsPublic is used to check if the type is Public.
IsSealed is used to check if the type is Sealed.
IsSerializable is used to check if the type is Serializable.
MemberType is used to check if the type is Member type of Nested type.
Module Gets the module of the type.
Name Gets the name of the type.
Method Description
GetConstructors() Returns all the public constructors for the Type.
GetConstructors(BindingFlag
s)
Returns all the constructors for the Type with specified
BindingFlags.
GetFields() Returns all the public fields for the Type.
GetFields(BindingFlags) Returns all the public constructors for the Type with specified
BindingFlags.
GetMembers() Returns all the public members for the Type.
GetMembers(BindingFlags) Returns all the members for the Type with specified BindingFlags.
GetMethods() Returns all the public methods for the Type.
GetMethods(BindingFlags) Returns all the methods for the Type with specified BindingFlags.
GetProperties() Returns all the public properties for the Type.
GetProperties(BindingFlags) Returns all the properties for the Type with specified
BindingFlags.
GetType() Gets the current Type.
GetType(String) Gets the Type for the given name.
For more visit our website
www.siri-kt.blogspot.com
Thanks for
Watching

More Related Content

What's hot

Access specifiers (Public Private Protected) C++
Access specifiers (Public Private  Protected) C++Access specifiers (Public Private  Protected) C++
Access specifiers (Public Private Protected) C++vivekkumar2938
 
Inner Classes
Inner ClassesInner Classes
Inner Classesparag
 
Master of Computer Application (MCA) – Semester 4 MC0078
Master of Computer Application (MCA) – Semester 4  MC0078Master of Computer Application (MCA) – Semester 4  MC0078
Master of Computer Application (MCA) – Semester 4 MC0078Aravind NC
 
OOPs difference faqs- 2
OOPs difference faqs- 2OOPs difference faqs- 2
OOPs difference faqs- 2Umar Ali
 
คำถาม 5 ข้อ
คำถาม 5 ข้อคำถาม 5 ข้อ
คำถาม 5 ข้อTavit Tangviriya
 
Access modifiers
Access modifiersAccess modifiers
Access modifiersJadavsejal
 
encapsulation and abstraction
encapsulation and abstractionencapsulation and abstraction
encapsulation and abstractionALIZAPARVIN
 
Object as function argument , friend and static function by shahzad younas
Object as function argument , friend and static function by shahzad younasObject as function argument , friend and static function by shahzad younas
Object as function argument , friend and static function by shahzad younasShahzad Younas
 
object oriented programming using c++
 object oriented programming using c++ object oriented programming using c++
object oriented programming using c++fasalsial1fasalsial1
 

What's hot (20)

Access specifiers (Public Private Protected) C++
Access specifiers (Public Private  Protected) C++Access specifiers (Public Private  Protected) C++
Access specifiers (Public Private Protected) C++
 
C# classes objects
C#  classes objectsC#  classes objects
C# classes objects
 
C# Access modifiers
C# Access modifiersC# Access modifiers
C# Access modifiers
 
java tutorial 4
 java tutorial 4 java tutorial 4
java tutorial 4
 
Inner Classes
Inner ClassesInner Classes
Inner Classes
 
C# Basics
C# BasicsC# Basics
C# Basics
 
Master of Computer Application (MCA) – Semester 4 MC0078
Master of Computer Application (MCA) – Semester 4  MC0078Master of Computer Application (MCA) – Semester 4  MC0078
Master of Computer Application (MCA) – Semester 4 MC0078
 
Python: Singleton Pattern
Python: Singleton PatternPython: Singleton Pattern
Python: Singleton Pattern
 
OOPs difference faqs- 2
OOPs difference faqs- 2OOPs difference faqs- 2
OOPs difference faqs- 2
 
คำถาม 5 ข้อ
คำถาม 5 ข้อคำถาม 5 ข้อ
คำถาม 5 ข้อ
 
Javasession8
Javasession8Javasession8
Javasession8
 
Access modifiers
Access modifiersAccess modifiers
Access modifiers
 
Constructor
ConstructorConstructor
Constructor
 
ICOM4015 CIIC4010 Exam Review #1
ICOM4015 CIIC4010 Exam Review #1 ICOM4015 CIIC4010 Exam Review #1
ICOM4015 CIIC4010 Exam Review #1
 
encapsulation and abstraction
encapsulation and abstractionencapsulation and abstraction
encapsulation and abstraction
 
[OOP - Lec 06] Classes and Objects
[OOP - Lec 06] Classes and Objects[OOP - Lec 06] Classes and Objects
[OOP - Lec 06] Classes and Objects
 
Object as function argument , friend and static function by shahzad younas
Object as function argument , friend and static function by shahzad younasObject as function argument , friend and static function by shahzad younas
Object as function argument , friend and static function by shahzad younas
 
Interfaces in java
Interfaces in javaInterfaces in java
Interfaces in java
 
Chapter 9 java
Chapter 9 javaChapter 9 java
Chapter 9 java
 
object oriented programming using c++
 object oriented programming using c++ object oriented programming using c++
object oriented programming using c++
 

Similar to 15reflection in c#

Reflection Slides by Zubair Dar
Reflection Slides by Zubair DarReflection Slides by Zubair Dar
Reflection Slides by Zubair Darzubairdar6
 
Practical type mining in Scala
Practical type mining in ScalaPractical type mining in Scala
Practical type mining in ScalaRose Toomey
 
Object Oriented Programming In .Net
Object Oriented Programming In .NetObject Oriented Programming In .Net
Object Oriented Programming In .NetGreg Sohl
 
Object-oriented programming
Object-oriented programmingObject-oriented programming
Object-oriented programmingNeelesh Shukla
 
Reflection in C Sharp
Reflection in C SharpReflection in C Sharp
Reflection in C SharpHarman Bajwa
 
Md02 - Getting Started part-2
Md02 - Getting Started part-2Md02 - Getting Started part-2
Md02 - Getting Started part-2Rakesh Madugula
 
Typescript: Beginner to Advanced
Typescript: Beginner to AdvancedTypescript: Beginner to Advanced
Typescript: Beginner to AdvancedTalentica Software
 
Reflecting On The Code Dom
Reflecting On The Code DomReflecting On The Code Dom
Reflecting On The Code DomNick Harrison
 
oops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdfoops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdfArpitaJana28
 
Using class and object java
Using class and object javaUsing class and object java
Using class and object javamha4
 
11 Using classes and objects
11 Using classes and objects11 Using classes and objects
11 Using classes and objectsmaznabili
 
Object-oriented Analysis, Design & Programming
Object-oriented Analysis, Design & ProgrammingObject-oriented Analysis, Design & Programming
Object-oriented Analysis, Design & ProgrammingAllan Mangune
 

Similar to 15reflection in c# (20)

Reflection
ReflectionReflection
Reflection
 
Reflection in C#
Reflection in C#Reflection in C#
Reflection in C#
 
Reflection Slides by Zubair Dar
Reflection Slides by Zubair DarReflection Slides by Zubair Dar
Reflection Slides by Zubair Dar
 
Generic
GenericGeneric
Generic
 
Lecture 8 Library classes
Lecture 8 Library classesLecture 8 Library classes
Lecture 8 Library classes
 
VB.net&OOP.pptx
VB.net&OOP.pptxVB.net&OOP.pptx
VB.net&OOP.pptx
 
Practical type mining in Scala
Practical type mining in ScalaPractical type mining in Scala
Practical type mining in Scala
 
Object Oriented Programming In .Net
Object Oriented Programming In .NetObject Oriented Programming In .Net
Object Oriented Programming In .Net
 
Objects and Types C#
Objects and Types C#Objects and Types C#
Objects and Types C#
 
Object-oriented programming
Object-oriented programmingObject-oriented programming
Object-oriented programming
 
Oops
OopsOops
Oops
 
Reflection in C Sharp
Reflection in C SharpReflection in C Sharp
Reflection in C Sharp
 
Md02 - Getting Started part-2
Md02 - Getting Started part-2Md02 - Getting Started part-2
Md02 - Getting Started part-2
 
Typescript: Beginner to Advanced
Typescript: Beginner to AdvancedTypescript: Beginner to Advanced
Typescript: Beginner to Advanced
 
Reflecting On The Code Dom
Reflecting On The Code DomReflecting On The Code Dom
Reflecting On The Code Dom
 
oops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdfoops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdf
 
Using class and object java
Using class and object javaUsing class and object java
Using class and object java
 
11 Using classes and objects
11 Using classes and objects11 Using classes and objects
11 Using classes and objects
 
Object-oriented Analysis, Design & Programming
Object-oriented Analysis, Design & ProgrammingObject-oriented Analysis, Design & Programming
Object-oriented Analysis, Design & Programming
 
Unit3 part1-class
Unit3 part1-classUnit3 part1-class
Unit3 part1-class
 

More from Sireesh K (20)

Cn10
Cn10Cn10
Cn10
 
chanakya neeti
chanakya neetichanakya neeti
chanakya neeti
 
chanakya neeti
chanakya neetichanakya neeti
chanakya neeti
 
What is mvc
What is mvcWhat is mvc
What is mvc
 
31c
31c31c
31c
 
31cs
31cs31cs
31cs
 
45c
45c45c
45c
 
44c
44c44c
44c
 
43c
43c43c
43c
 
42c
42c42c
42c
 
41c
41c41c
41c
 
40c
40c40c
40c
 
39c
39c39c
39c
 
38c
38c38c
38c
 
37c
37c37c
37c
 
35c
35c35c
35c
 
34c
34c34c
34c
 
33c
33c33c
33c
 
30c
30c30c
30c
 
29c
29c29c
29c
 

Recently uploaded

Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 

Recently uploaded (20)

Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 

15reflection in c#

  • 2. C# Tutorial Part 15 : Reflection www.siri-kt.blogspot.com
  • 3. • Reflection objects are used for obtaining type information at runtime. The classes that give access to the metadata of a running program are in theSystem.Reflection namespace. • The System.Reflection namespace contains classes that allow you to obtain information about the application and to dynamically add types, values, and objects to the application. • Reflection has the following applications: • It allows view attribute information at runtime. • It allows examining various types in an assembly and instantiate these types. • It allows late binding to methods and properties • It allows creating new types at runtime and then performs some tasks using those types. • Viewing Metadata • We have mentioned in the preceding chapter that using reflection you can view the attribute information. • The MemberInfo object of the System.Reflection class needs to be initialized for discovering the attributes associated with a class.
  • 4. • In C#, reflection is a process to get metadata of a type at runtime. The System.Reflection namespace contains required classes for reflection such as: • Type • MemberInfo • ConstructorInfo • MethodInfo • FieldInfo • PropertyInfo • TypeInfo • EventInfo • Module • Assembly • AssemblyName • Pointer etc. • The System.Reflection.Emit namespace contains classes to emit
  • 5. • C# Type class • C# Type class represents type declarations for class types, interface types, enumeration types, array types, value types etc. It is found in System namespace. It inherits System.Reflection.MemberInfo class.
  • 6. Property Description Assembly Gets the Assembly for this type. AssemblyQualifiedName Gets the Assembly qualified name for this type. Attributes Gets the Attributes associated with the type. BaseType Gets the base or parent type. FullName Gets the fully qualified name of the type. IsAbstract is used to check if the type is Abstract. IsArray is used to check if the type is Array. IsClass is used to check if the type is Class. IsEnum is used to check if the type is Enum. IsInterface is used to check if the type is Interface. IsNested is used to check if the type is Nested. IsPrimitive is used to check if the type is Primitive. IsPointer is used to check if the type is Pointer. IsNotPublic is used to check if the type is not Public. IsPublic is used to check if the type is Public. IsSealed is used to check if the type is Sealed. IsSerializable is used to check if the type is Serializable. MemberType is used to check if the type is Member type of Nested type. Module Gets the module of the type. Name Gets the name of the type.
  • 7. Method Description GetConstructors() Returns all the public constructors for the Type. GetConstructors(BindingFlag s) Returns all the constructors for the Type with specified BindingFlags. GetFields() Returns all the public fields for the Type. GetFields(BindingFlags) Returns all the public constructors for the Type with specified BindingFlags. GetMembers() Returns all the public members for the Type. GetMembers(BindingFlags) Returns all the members for the Type with specified BindingFlags. GetMethods() Returns all the public methods for the Type. GetMethods(BindingFlags) Returns all the methods for the Type with specified BindingFlags. GetProperties() Returns all the public properties for the Type. GetProperties(BindingFlags) Returns all the properties for the Type with specified BindingFlags. GetType() Gets the current Type. GetType(String) Gets the Type for the given name.
  • 8. For more visit our website www.siri-kt.blogspot.com Thanks for Watching