C#:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace AssemblyAttributesCS
{
    
class Program
    {
        
static void Main(string[] args)
        {
            Assembly a 
= Assembly.GetExecutingAssembly();
            Type assemblyType 
= typeof(AssemblyDescriptionAttribute);
            
object[] attributes = a.GetCustomAttributes(assemblyType, false);
            
if (attributes.Length > 0)
            {
                AssemblyDescriptionAttribute ada 
= attributes[0as AssemblyDescriptionAttribute;
                Console.WriteLine(
"Description is {0}", ada.Description);
            }
            Console.Read();
        }
    }
}


VB.NET:

Imports System.Reflection
Module Module1

    
Sub Main()
        
Dim a As Assembly = Assembly.GetExecutingAssembly()
        
Dim assemblyType As Type = GetType(AssemblyDescriptionAttribute)
        
Dim attributes As Object() = a.GetCustomAttributes(assemblyType, False)
        
If attributes.Length > 0 Then
            
Dim ada As AssemblyDescriptionAttribute = CType(attributes(0), AssemblyDescriptionAttribute)
            Console.WriteLine(
"Description is {0}", ada.Description)
        
End If
        Console.Read()
    
End Sub

End Module

 

相关文章:

  • 2021-07-07
  • 2021-12-08
  • 2022-01-24
  • 2022-01-12
  • 2021-06-28
  • 2021-08-18
  • 2021-11-22
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-31
  • 2021-05-27
  • 2022-12-23
相关资源
相似解决方案