December 2018
Beginner to intermediate
668 pages
15h 30m
English
Add a new console application project named WorkingWithReflection.
At the top of the file, import the following types and namespaces:
using static System.Console; using System; using System.Reflection;
In the Main method, enter statements to get the console apps assembly, output its name and location, and get all assembly-level attributes and output their types, as shown in the following code:
WriteLine("Assembly metadata:");Assembly assembly = Assembly.GetEntryAssembly();WriteLine($" Full name: {assembly.FullName}");WriteLine($" Location: {assembly.Location}");var attributes = assembly.GetCustomAttributes();WriteLine($" Attributes:");foreach (Attribute a in attributes){ WriteLine($" {a.GetType()}");}
Run the console ...
Read now
Unlock full access