22.5. Summary

C#'s reflection lets you view and query metadata, dynamically invoke methods, set fields, and call constructors on any C# type. You can also define custom types and use reflection emit to dynamically manipulate the generated IL. Java's reflection API, in contrast, does not allow you to manipulate the generated byte code.

One noteworthy difference between the Java and C# reflection APIs is that in C#, the reflection methods that search for a particular member of a type, based on its signature, return null instead of throwing an exception. This is ideologically different from the Java world, where the nonexistence of something is usually indicated by throwing a checked exception instead of returning null. Java programmers who are ...

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.