22.1. The Core Reflection Classes

The core classes for reflection in C# are stored in the System.Reflection namespace. The close equivalents to those classes in Java can be found in the java.lang.reflect and java.lang packages.

System.Type is the core C# class from which all reflective discovery is done. This class is roughly equivalent to the java.lang.Class class. However, there is a difference. In Java, everything is a java.lang.Object, so java.lang.Class is the metadata of all objects. In C#, System.Type can represent any of the following types: classes, value types, arrays, pointers, interfaces, and enumerations. The C# typeof operator is somewhat equivalent to the .class operator in Java. To get metadata about the System.String class, you ...

Get .NET for Java Developers: Migrating to C# now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.