Reading Assembly Attributes C# with Example



Reading Assembly Attributes C# with Example

Using .NET's rich reflection APIs, you can gain access to an assembly's metadata. For example, you can get this 
assembly's title attribute with the following code 
using System.Linq; 
using System.Reflection; 
... 
Assembly assembly = typeof(this).Assembly; 
var titleAttribute = assembly.GetCustomAttributes().FirstOrDefault(); 
 

Console.WriteLine($"This assembly title is {titleAttribute?.Title}"); 
 

Application using a Plain-Text Editor and 
the C# Compiler (csc.exe) 

0 Comment's

Comment Form

Submit Comment