---
title: "Reflection in C#"  
description: "In this blog, I’m explaining about Reflection in .Net  Reflection is the process by which program can read its own metadata. Reflection provides obje"  
author: "priyanka kushwaha"  
published: 2015-01-27  
updated: 2015-01-27  
canonical: https://www.mindstick.com/blog/733/reflection-in-c-sharp  
category: ".net"  
tags: ["c#", ".net", "reflection"]  
reading_time: 1 minute  

---

# Reflection in C#

In this blog, I’m explaining about [Reflection](https://www.mindstick.com/articles/13004/how-to-write-a-reflection-paper) in .Net\

Reflection is the [process](https://yourviews.mindstick.com/story/1525/7-important-factors-that-may-affect-the-learning-process) by which [program](https://www.mindstick.com/blog/12337/scaling-up-your-mentorship-program) can read its own metadata. Reflection provides [objects](https://www.mindstick.com/forum/145447/what-are-objects) (typeof Type) that encapsulate assemblies, [modules](https://www.mindstick.com/interview/266/what-is-the-use-of-http-modules) and types. You can use reflection to dynamically create an [instance](https://www.mindstick.com/forum/1739/object-reference-is-not-set-to-an-instance-of-an-object-error-in-my-code) of a type, bind the type to an existing object, or get the type from an existing object and invoke its [methods](https://www.mindstick.com/articles/13060/runny-nose-remedy-methods-that-work-best) or [access](https://www.mindstick.com/articles/12994/how-foreigners-can-access-blocked-websites-in-china) its fields and properties. If you are using [attributes](https://www.mindstick.com/articles/13105/2-attributes-that-make-your-odoo-ecommerce-theme-productive-and-engaging) in [your code](https://www.mindstick.com/forum/157976/how-can-you-use-jquery-s-testing-framework-such-as-qunit-to-write-unit-tests-for-your-code), Reflection enables to access them.

##### Example

```
namespace ReflectionProgram{ public class Operation    {    public  int add(int x, int y)        {            return (x + y);        }       public  int subtract(int x, int y)        {            return (x - y);        }      private string topic;    }         class Program    {        static void Main(string[] args)        {           Type  t  =typeof(Operation);           MemberInfo[] mi = t.GetMethods();            object[] parameters = new object[2];            parameters[0] = 32;            parameters[1] = 12;           object obj =Activator.CreateInstance(t);              int res = (int)t.InvokeMember(mi[3].Name, BindingFlags.InvokeMethod,null, obj, parameters);               Console.WriteLine(res);           var info = typeof(System.Int32).Assembly;           Console.WriteLine(info);           Console.ReadKey();        }    }}
```

---

Original Source: https://www.mindstick.com/blog/733/reflection-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
