Category Archives: reflection

Use the automatic code converters at developerFusion to convert C# code into Visual Basic, Ruby, and Python

The developerFusion web site provides code converters that let you translate between C#, Visual Basic, Ruby, and Python. One of the most important uses for reflection is analyzing code to figure out what it does. Once you know what the … Continue reading

Posted in programs, reflection, syntax | Tagged , , , , , , , , , , , , , , , | 5 Comments

Use reflection to list a class’s events in C#

This example uses the following code to add some simple events to the Form1 class. // Make some events. public delegate int MyPublicDelegate(string index); public event MyPublicDelegate MyPublicEvent; private delegate int MyPrivateDelegate(string index); private event MyPrivateDelegate MyPrivateEvent; public virtual event … Continue reading

Posted in reflection | Tagged , , , , , , , , , | Leave a comment

Use reflection to list a class’s methods in C#

This example uses the following code to add some simple methods to the Form1 class. // Add some methods. private void MyPrivateMethod(string arg0, string arg2) { } public void MyPublicMethod(float float0, double double0) { } private void MyOverloadedMethod() { } … Continue reading

Posted in reflection | Tagged , , , , , , , , , | Leave a comment

Use reflection to list the fields provided by the SystemInformation class in C#

The example Use reflection to list a class’s fields in C# shows how to list the fields defined by a class. This example uses the techniques described in that example to list the few fields defined by the SystemInformation class. … Continue reading

Posted in reflection | Tagged , , , , , , , , , , , , , | Leave a comment

Use reflection to list a class’s fields in C#

Even though fields and properties are very similar when you interact with an item in code, to C# they are different. One side effect of that is that the GetProperties method provided by reflection lists only properties, not fields. Fortunately, … Continue reading

Posted in reflection | Tagged , , , , , , , , , , , , | 2 Comments

Use reflection to list SystemInformation properties in C#

This example shows how you can use reflection to get the properties defined by the SystemInformation class. The SystemInformation class is chock-full of useful properties that give information about system parameters. These include such values as the thickness of a … Continue reading

Posted in reflection | Tagged , , , , , , , , , , , | 2 Comments

Use reflection to list a class’s properties in C#

This post begins a short series on using reflection. The tools that make C# work (such as the .NET Framework and the compiler that turns C# into IL code) use techniques that require them to learn a lot about the … Continue reading

Posted in reflection | Tagged , , , , , , , , , , | 4 Comments

Display tooltips on a graph of an equation entered by the user in C#

This example draws a graph of an equation entered by the user and the displays a tooltip on it when you move the mouse over the graph. See the post Graph equations entered by the user in C# for information … Continue reading

Posted in algorithms, drawing, graphics, mathematics, reflection | Tagged , , , , , , , , , , , | Leave a comment

Find class ancestors in C#

The example Find classes that implement an interface or that are descendants of a given class in C# shows how to find a list of classes that are descendants of a class or interface. This example uses similar code to … Continue reading

Posted in classes, inheritance, interfaces, reflection | Tagged , , , , , , , , , , , , , , , | Leave a comment

Find classes that implement an interface or that are descendants of a given class in C#

This example lets you find classes that are part of an inheritance or implementation hierarchy. When you enter a class or interface name and click Find, the example uses the following code to search the currently loaded assemblies for classes … Continue reading

Posted in classes, inheritance, interfaces, reflection | Tagged , , , , , , , , , , , , , , | 1 Comment