C# Type Assembly

Description

Type Assembly gets the Assembly in which the type is declared. For generic types, gets the Assembly in which the generic type is defined.

Syntax

Type.Assembly has the following syntax.


public abstract Assembly Assembly { get; }

Example

The following example displays the assembly name associated with the class and the fully qualified name of the type.


using System;/*  ww  w.  j a v a  2 s  . c  o  m*/
using System.Reflection;

class MyAssemblyClass
{
    public static void Main()
    {
        Type objType = typeof(System.Array);

        // Print the full assembly name.
        Console.WriteLine ("Full assembly name:\n   {0}.", 
                           objType.Assembly.FullName.ToString()); 

        // Print the qualified assembly name.
        Console.WriteLine ("Qualified assembly name:\n   {0}.", 
                           objType.AssemblyQualifiedName.ToString()); 
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version