Chapter 8

Creating and Using Types with Reflection, Custom Attributes, the CodeDOM, and Lambda Expressions

What You Will Learn in this Chapter

  • Using the System.Reflection namespace
  • Reading and creating custom attributes
  • Generating code using the CodeDOM namespace
  • Understanding lambda expressions


You can find the code downloads for this chapter at on the Download Code tab. The code is in the chapter08 download and individually named according to the names throughout the chapter.

This chapter has a mix of topics that will be covered on the exam, and these four topics do not directly relate to each other. The first three topics cover features that can be used to examine, customize, or generate C# code, while the last topic explains how to write shorthand syntax for your existing methods. It is especially important to understand the concept of lambda expressions because not only will you see them used extensively in Chapter 10, “Working with Language Integrated Query (LINQ),” but you will see questions on the test that use lambda expressions and you could be asked what the result of the expression would be.

Table 8-1 introduces you to the exam objectives covered in this chapter.

Table 8-1: 70-483 Exam Objectives Covered in This Chapter

ObjectiveContent Covered
Create and use typesReflection. This includes finding, executing, and creating types at run time. Attributes. This includes creating, applying, ...

Get MCSD Certification Toolkit (Exam 70-483): Programming in C# now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.