Dynamically Calling Methods
page 2 of 7
by . .
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 29429/ 83

Reflection

Types

Later on I will go into this in greater detail, but this will be just a quick overview here.

You probably know that when you create a class, you are essentially creating a type. A lot of people underestimate the power of a type, you may have used GetType once in a while, but you may not know the underlying power of it. The Type class contains a heck of a lot of information about an type that you can access and then can lead on to some pretty interesting abilities.

System.Reflection

The System.Reflection namespace contains all of the tools needed to provide a view (in code) of any assembly in .NET. If you take a look at the Object Browser in VS.NET, that is the equivalent of using System.Reflection to find out about all of that information. Intellisense in VS.NET is also like using System.Reflection and Lutz Roeder's .NET Reflector uses System.Reflection to browse an assembly.

But why would you use System.Reflection?

Let's say that you were given an assembly and you have no idea what it contains or does, you could use reflection to find out what's in it and how it works.
Or, if you were developing a dynamic documentation system, then you could just place an assembly in the /bin directory and develop an application that used reflection to dynamically generate information and documentation about the assembly (much like the Comment Web Pages with XML Code Comments in VS.NET).

MethodInfo

MethodInfo is a class within System.Reflection that allows you to get information about specific methods (which I will be using in this article). For example, you can give it a method and you can get all sorts of properties and methods back which you can use to examine that method.


View Entire Article

User Comments

No comments posted yet.

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-05-18 11:47:09 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search