Tôi đã đọc qua một cuốn sách .NET 2.0 và đã xem qua mẫu mã này mà được mô tả ứng dụng lắp ráp:Cách đơn giản hóa để có được mô tả lắp ráp trong C#?
static void Main(string[] args)
{
Assembly assembly = Assembly.GetExecutingAssembly();
object[] attributes =
assembly.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false);
if (attributes.Length > 0)
{
AssemblyDescriptionAttribute descriptionAttribute =
(AssemblyDescriptionAttribute)attributes[0];
Console.WriteLine(descriptionAttribute.Description);
}
Console.ReadKey();
}
Đó là khá nhiều mã để chỉ đơn giản nhận được mô tả lắp ráp và tôi muốn biết nếu có một cách đơn giản hơn để làm điều này trong .NET 3.5+ sử dụng LINQ hoặc lambda biểu thức?
tôi nghĩ rằng mã này là đủ tốt –