Tag Archives: properties

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

Make a default indexer property for a class in C#

Classes such as Dictionary and List provide a default indexer property that lets you access values using a syntax similar to the one you use to access values in an array. For example, the following code sets and then gets … Continue reading

Posted in classes, OOP | Tagged , , , , , , , , , , , , | Leave a comment

Let controls share event handlers in C#

Sometimes it would be useful to let controls share event handlers. Often a program has several controls that do almost the same thing. It would be nice if they could share the same event handler to increase code reuse, but … Continue reading

Posted in controls, methods | Tagged , , , , , , , , , , , , | Leave a comment

Use resources to hold images, text, and other data, and load it at run time in C#

Resources are images, strings, text files, and other pieces of data that you can build into an application. Your program can load the resources at run time to display new pictures, text, or whatever. To add resources to the project, … Continue reading

Posted in controls, graphics, strings | Tagged , , , , , , , , , , | Leave a comment