Search⌘ K
AI Features

Revealing the Extent of C# Vocabulary

Explore how to count and list all types and their methods in a C# console app using reflection. Learn to import namespaces, manipulate program code, and see how declaring variables affects loaded assemblies and accessible types.

We know there are more than 100 keywords in C#, but how many types are there? Let’s write code to determine how many types (and their methods) are available to C# in our simple console app.

Counting the types and methods

Don’t worry about exactly how this code works for now, but know that it uses a technique called reflection:

Step 1: Delete all the existing statements in Program.cs.

Step 2: We’ll ...