O'Reilly logo

.NET Common Language Runtime Unleashed by Kevin Burton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Dynamic Generation of Code

Up to this point, the reflection services have been used to read type information at runtime. It is also possible to have your code build code. Dynamically building and running code is used in a number of different places throughout the .NET Framework. Two such examples are the Regex (regular expression) class and the XmlSerializer class. The tools are available for you to generate your own code by using code.

This section first discusses a simple “Hello World!” sample in which a single function can generate code for all of the languages supported. This function builds a code tree and then hands the tree over to the code generation APIs. This section will then delve into a more real-world sample where you gain improvement ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required