Type.FullName 속성

정의

해당 네임스페이스는 포함하지만 어셈블리는 포함하지 않는 형식의 정규화된 이름을 가져옵니다.

public:
 abstract property System::String ^ FullName { System::String ^ get(); };
public abstract string FullName { get; }
public abstract string? FullName { get; }
member this.FullName : string
Public MustOverride ReadOnly Property FullName As String

속성 값

String

해당 네임스페이스는 포함하지만 어셈블리는 포함하지 않는 형식의 정규화된 이름이거나 현재 인스턴스가 제네릭 형식 매개 변수, 배열 형식, 포인터 형식, 형식 매개 변수에 기초한 null 형식 또는 제네릭 형식 정의가 아니지만 확인되지 않은 형식 매개 변수가 들어 있는 제네릭 형식인 경우에는 byref입니다.

구현

예제

다음 예에서는 지정 된 형식의 전체 이름을 표시 합니다.

using namespace System;
int main()
{
   Type^ t = Array::typeid;
   Console::WriteLine( "The full name of the Array type is {0}.", t->FullName );
}

/* This example produces the following output:

The full name of the Array type is System.Array.
 */
using System;
class TestFullName
{
public static void Main()
    {
    Type t = typeof(Array);
    Console.WriteLine("The full name of the Array type is {0}.", t.FullName);
    }
}

/* This example produces the following output:

The full name of the Array type is System.Array.
 */
Class TestFullName
   
    Public Shared Sub Main()
        Dim t As Type = GetType(Array)
        Console.WriteLine("The full name of the Array type is {0}.", t.FullName)
    End Sub
End Class

' This example produces the following output:
'
'The full name of the Array type is System.Array.
'

다음 예제에서는 ToString 메서드 및 Name , FullName 및 속성이 반환 하는 문자열을 비교 합니다 AssemblyQualifiedName .

using System;
using System.Collections.Generic;
using System.Globalization;

public class Example
{
    public static void Main()
    {
        Type t = typeof(String);
        ShowTypeInfo(t);

        t = typeof(List<>);
        ShowTypeInfo(t);

        var list = new List<String>();
        t = list.GetType();
        ShowTypeInfo(t);

        Object v = 12;
        t = v.GetType();
        ShowTypeInfo(t);

        t = typeof(IFormatProvider);
        ShowTypeInfo(t);

        IFormatProvider ifmt = NumberFormatInfo.CurrentInfo;
        t = ifmt.GetType();
        ShowTypeInfo(t);
    }

    private static void ShowTypeInfo(Type t)
    {
        Console.WriteLine($"Name: {t.Name}");
        Console.WriteLine($"Full Name: {t.FullName}");
        Console.WriteLine($"ToString:  {t}");
        Console.WriteLine($"Assembly Qualified Name: {t.AssemblyQualifiedName}");
        Console.WriteLine();
    }
}
// The example displays output like the following:
//    Name: String
//    Full Name: System.String
//    ToString:  System.String
//    Assembly Qualified Name: System.String, mscorlib, Version=4.0.0.0, Culture=neutr
//    al, PublicKeyToken=b77a5c561934e089
//
//    Name: List`1
//    Full Name: System.Collections.Generic.List`1
//    ToString:  System.Collections.Generic.List`1[T]
//    Assembly Qualified Name: System.Collections.Generic.List`1, mscorlib, Version=4.
//    0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
//
//    Name: List`1
//    Full Name: System.Collections.Generic.List`1[[System.String, mscorlib, Version=4
//    .0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]
//    ToString:  System.Collections.Generic.List`1[System.String]
//    Assembly Qualified Name: System.Collections.Generic.List`1[[System.String, mscor
//    lib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorl
//    ib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
//
//    Name: Int32
//    Full Name: System.Int32
//    ToString:  System.Int32
//    Assembly Qualified Name: System.Int32, mscorlib, Version=4.0.0.0, Culture=neutra
//    l, PublicKeyToken=b77a5c561934e089
//
//    Name: IFormatProvider
//    Full Name: System.IFormatProvider
//    ToString:  System.IFormatProvider
//    Assembly Qualified Name: System.IFormatProvider, mscorlib, Version=4.0.0.0, Cult
//    ure=neutral, PublicKeyToken=b77a5c561934e089
//
//    Name: NumberFormatInfo
//    Full Name: System.Globalization.NumberFormatInfo
//    ToString:  System.Globalization.NumberFormatInfo
//    Assembly Qualified Name: System.Globalization.NumberFormatInfo, mscorlib, Versio
//    n=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Imports System.Collections.Generic
Imports System.Globalization

Module Example
    Public Sub Main()
        Dim t As Type = GetType(String)
        ShowTypeInfo(t)

        t = GetType(List(Of))
        ShowTypeInfo(t)

        Dim list As New List(Of String)()
        t = list.GetType()
        ShowTypeInfo(t)

        Dim v As Object = 12
        t = v.GetType()
        ShowTypeInfo(t)

        t = GetType(IFormatProvider)
        ShowTypeInfo(t)

        Dim ifmt As IFormatProvider = NumberFormatInfo.CurrentInfo
        t = ifmt.GetType()
        ShowTypeInfo(t)
    End Sub

    Private Sub ShowTypeInfo(t As Type)
        Console.WriteLine($"Name: {t.Name}")
        Console.WriteLine($"Full Name: {t.FullName}")
        Console.WriteLine($"ToString:  {t}")
        Console.WriteLine($"Assembly Qualified Name: {t.AssemblyQualifiedName}")
        Console.WriteLine()
    End Sub
End Module
' The example displays output like the following:
'    Name: String
'    Full Name: System.String
'    ToString:  System.String
'    Assembly Qualified Name: System.String, mscorlib, Version=4.0.0.0, Culture=neutr
'    al, PublicKeyToken=b77a5c561934e089
'
'    Name: List`1
'    Full Name: System.Collections.Generic.List`1
'    ToString:  System.Collections.Generic.List`1[T]
'    Assembly Qualified Name: System.Collections.Generic.List`1, mscorlib, Version=4.
'    0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
'
'    Name: List`1
'    Full Name: System.Collections.Generic.List`1[[System.String, mscorlib, Version=4
'    .0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]
'    ToString:  System.Collections.Generic.List`1[System.String]
'    Assembly Qualified Name: System.Collections.Generic.List`1[[System.String, mscor
'    lib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorl
'    ib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
'
'    Name: Int32
'    Full Name: System.Int32
'    ToString:  System.Int32
'    Assembly Qualified Name: System.Int32, mscorlib, Version=4.0.0.0, Culture=neutra
'    l, PublicKeyToken=b77a5c561934e089
'
'    Name: IFormatProvider
'    Full Name: System.IFormatProvider
'    ToString:  System.IFormatProvider
'    Assembly Qualified Name: System.IFormatProvider, mscorlib, Version=4.0.0.0, Cult
'    ure=neutral, PublicKeyToken=b77a5c561934e089
'
'    Name: NumberFormatInfo
'    Full Name: System.Globalization.NumberFormatInfo
'    ToString:  System.Globalization.NumberFormatInfo
'    Assembly Qualified Name: System.Globalization.NumberFormatInfo, mscorlib, Versio
'    n=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

설명

예를 들어 형식의 정규화 된 이름은 String System.String 입니다. 이는 AssemblyQualifiedName 전체 이름과 전체 어셈블리 이름으로 구성 되는 속성에 의해 반환 되는 어셈블리로 한정 된 이름과 대조 됩니다.

현재 형식이 폐쇄형 제네릭 형식을 나타내는 경우 FullName 제네릭 형식 자체의 문자열 표현이 전체 어셈블리 이름으로 한정 되지 않더라도 속성에 의해 반환 되는 문자열의 형식 인수는 전체 어셈블리 이름으로 정규화 됩니다. 다음 예제에서는 제네릭 형식 정의를 나타내는 형식과 폐쇄형 제네릭 형식을 나타내는 형식에 대 한 FullName 속성의 차이점을 보여 줍니다.

using System;
using System.Collections.Generic;

public class Example
{
   public static void Main()
   {
      Type t = typeof(List<>);
      Console.WriteLine(t.FullName);
      Console.WriteLine();

      List<String> list = new List<String>();
      t = list.GetType();
      Console.WriteLine(t.FullName);
   }
}
// The example displays the following output:
// System.Collections.Generic.List`1
//
// System.Collections.Generic.List`1[[System.String, mscorlib,
//        Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]
Imports System.Collections.Generic

Module Example
   Public Sub Main()
      Dim t As Type = GetType(List(Of))
      Console.WriteLine(t.FullName)
      Console.WriteLine()

      Dim list As New List(Of String)()
      t = list.GetType()
      Console.WriteLine(t.FullName)
   End Sub
End Module
' The example displays the following output:
'    System.Collections.Generic.List`1
'
'    System.Collections.Generic.List`1[[System.String, mscorlib,
'             Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]

이 속성은 null 다음과 같은 경우을 반환 합니다.

  • 현재 Type 개체가 제네릭 형식의 형식 매개 변수를 나타냅니다.

    다음 예제에서는 형식의 형식 매개 변수를 검색 하 Nullable<T> 고 해당 속성을 표시 하려고 합니다 FullName .

    using System;
    using System.Reflection;
    
    public class Example
    {
       public static void Main()
       {
          Type t = typeof(Nullable<>); 
          Console.WriteLine(t.FullName);
          if (t.IsGenericType) {
             Console.Write("   Generic Type Parameters: ");
             Type[] gtArgs = t.GetGenericArguments();
             for (int ctr = 0; ctr < gtArgs.Length; ctr++) {
                Console.WriteLine(gtArgs[ctr].FullName ??
                                  "(unassigned) " + gtArgs[ctr].ToString());
              }
             Console.WriteLine();
          }
       }
    }
    // The example displays the following output:
    //       System.Nullable`1
    //          Generic Type Parameters: (unassigned) T
    
    Imports System.Reflection
    
    Module Example
       Public Sub Main()
          Dim t As Type = GetType(Nullable(Of )) 
          Console.WriteLine(t.FullName)
          If t.IsGenericType Then
             Console.Write("   Generic Type Parameters: ")
             Dim gtArgs As Type() = t.GetGenericArguments
             For ctr As Integer = 0 To gtArgs.Length - 1
                Console.WriteLine(If(gtArgs(ctr).FullName, 
                                  "(unassigned) " + gtArgs(ctr).ToString()))
                If ctr < gtArgs.Length - 1 Then Console.Write(", ")   
             Next
             Console.WriteLine()
          End If
       End Sub
    End Module
    ' The example displays the following output:
    '       System.Nullable`1
    '          Generic Type Parameters: (unassigned) T
    
  • 현재 Type 개체는 배열 형식, 포인터 형식 또는 byref 제네릭 형식 매개 변수를 기반으로 하는 형식을 나타냅니다.

    다음 예제에서는 라는 세 개의 메서드를 사용 하 여 제네릭 형식을 정의 합니다. 여기에는 t 형식의 배열이 전달 되 고,는 t 개체로 전달 되 Generictype1<T> Display(T[]) 고,는 t HandleT(T) ChangeValue(ref T) 개체가 참조로 전달 됩니다. c # 및 Visual Basic에서는 T를 메서드에 포인터로 정의 하는 것을 허용 하지 않으므로 HandleT MakePointerType Type 제네릭 형식에 대 한 포인터를 만들려면 메서드의 매개 변수 형식을 나타내는 개체에서 메서드를 호출 해야 합니다. 예제의 출력에는 세 가지 경우 모두에서 속성이 인 것으로 표시 되어 FullName null 있습니다.

    using System;
    using System.Reflection;
    
    public class GenericType1<T> 
    {
       public void Display(T[] elements)  
       {}
       
       public void HandleT(T obj)
       {}
       
       public bool ChangeValue(ref T arg) 
       {
          return true;
       }
    }
    
    public class Example
    {
       public static void Main()
       {
          Type t = typeof(GenericType1<>);
          Console.WriteLine("Type Name: {0}", t.FullName);
          MethodInfo[] methods = t.GetMethods(BindingFlags.Instance |
                                              BindingFlags.DeclaredOnly |
                                              BindingFlags.Public);
          foreach (var method in methods) { 
             Console.WriteLine("   Method: {0}", method.Name);
             // Get method parameters.
             ParameterInfo param = method.GetParameters()[0];
             Type paramType = param.ParameterType;
             if (method.Name == "HandleT")
                paramType = paramType.MakePointerType();
             Console.WriteLine("      Parameter: {0}", 
                               paramType.FullName ?? 
                               paramType.ToString() + " (unassigned)");
          }
       }
    }
    // The example displays the following output:
    //       Type Name: GenericType1`1
    //          Method: Display
    //             Parameter: T[] (unassigned))
    //          Method: HandleT
    //             Parameter: T* (unassigned)
    //          Method: ChangeValue
    //             Parameter: T& (unassigned)
    
    Imports System.Reflection
    
    Public Class GenericType1(Of T)
       Public Sub Display(elements As T())
       End Sub
       
       ' Visual Basic does not support pointer types.
       Public Sub HandleT(obj As T)
       End Sub
       
       
       Public Function ChangeValue(ByRef arg As T) As Boolean
          Return True
       End Function
    End Class
    
    Module Example
       Public Sub Main()
          Dim t As Type = GetType(GenericType1(Of ))
          Console.WriteLine("Type Name: {0}", t.FullName)
          Dim methods() As MethodInfo = t.GetMethods(BindingFlags.Instance Or
                                                     BindingFlags.DeclaredOnly Or
                                                     BindingFlags.Public)
          For Each method In methods 
             Console.WriteLine("   Method: {0}", method.Name)
             ' Get method parameters.
             Dim param As ParameterInfo = method.GetParameters()(0)
             Dim paramType As Type = param.ParameterType
             If method.Name = "HandleT" Then
                paramType = paramType.MakePointerType()
             End If
             Console.WriteLine("      Parameter: {0}", 
                               If(paramType.FullName, 
                                  paramType.ToString() + " (unassigned)"))
          Next
       End Sub
    End Module
    ' The example displays the following output:
    '       Type Name: GenericType1`1
    '          Method: Display
    '             Parameter: T[] (unassigned)
    '          Method: HandleT
    '             Parameter: T* (unassigned)
    '          Method: ChangeValue
    '             Parameter: T& (unassigned)
    
  • 현재 형식에 특정 형식으로 대체 되지 않은 제네릭 형식 매개 변수가 포함 되어 있습니다. 즉, ContainsGenericParameters 속성이를 반환 true 하지만 형식이 제네릭 형식 정의가 아닙니다. 즉, IsGenericTypeDefinition 속성이를 반환 합니다. false

    다음 예제에서는 Derived<T> 에서 상속 Base<T> 됩니다. BaseType속성은 Type 의 기본 형식을 나타내는 개체를 가져오고 Derived<T> 해당 속성은를 FullName 반환 null 합니다.

    using System;
    using System.Reflection;
    
    public class Base<T> { }
    
    public class Derived<T> : Base<T> { }
    
    public class Example
    {
       public static void Main()
       {
          Type t = typeof(Derived<>);
          Console.WriteLine("Generic Class: {0}", t.FullName);
          Console.WriteLine("   Contains Generic Paramters: {0}",
                            t.ContainsGenericParameters);
          Console.WriteLine("   Generic Type Definition: {0}\n",
                            t.IsGenericTypeDefinition);                 
    
          Type baseType = t.BaseType;
          Console.WriteLine("Its Base Class: {0}", 
                            baseType.FullName ?? 
                            "(unassigned) " + baseType.ToString());
          Console.WriteLine("   Contains Generic Paramters: {0}",
                            baseType.ContainsGenericParameters);
          Console.WriteLine("   Generic Type Definition: {0}",
                            baseType.IsGenericTypeDefinition);                 
          Console.WriteLine("   Full Name: {0}\n", 
                            baseType.GetGenericTypeDefinition().FullName);
    
          t = typeof(Base<>);
          Console.WriteLine("Generic Class: {0}", t.FullName);
          Console.WriteLine("   Contains Generic Paramters: {0}",
                            t.ContainsGenericParameters);
          Console.WriteLine("   Generic Type Definition: {0}\n",
                            t.IsGenericTypeDefinition);                 
       }
    }
    // The example displays the following output:
    //       Generic Class: Derived`1
    //          Contains Generic Paramters: True
    //          Generic Type Definition: True
    //       
    //       Its Base Class: (unassigned) Base`1[T]
    //          Contains Generic Paramters: True
    //          Generic Type Definition: False
    //          Full Name: Base`1
    //       
    //       Generic Class: Base`1
    //          Contains Generic Paramters: True
    //          Generic Type Definition: True
    
    Imports System.Reflection
    
    Public Class Base(Of T)
    End Class
    
    Public Class Derived(Of T) : Inherits Base(Of T)
    End Class
    
    Module Example
       Public Sub Main()
          Dim t As Type = GetType(Derived(Of ))
          Console.WriteLine("Generic Class: {0}", t.FullName)
          Console.WriteLine("   Contains Generic Paramters: {0}",
                            t.ContainsGenericParameters)
          Console.WriteLine("   Generic Type Definition: {0}",
                            t.IsGenericTypeDefinition)                 
          Console.WriteLine()
          
          Dim baseType As Type = t.BaseType
          Console.WriteLine("Its Base Class: {0}", 
                            If(baseType.FullName,  
                            "(unassigned) " + baseType.ToString()))
          Console.WriteLine("   Contains Generic Paramters: {0}",
                            baseType.ContainsGenericParameters)
          Console.WriteLine("   Generic Type Definition: {0}",
                            baseType.IsGenericTypeDefinition)                 
          Console.WriteLine("   Full Name: {0}", 
                            baseType.GetGenericTypeDefinition().FullName)
          Console.WriteLine()
          
          t = GetType(Base(Of ))
          Console.WriteLine("Generic Class: {0}", t.FullName)
          Console.WriteLine("   Contains Generic Paramters: {0}",
                            t.ContainsGenericParameters)
          Console.WriteLine("   Generic Type Definition: {0}",
                            t.IsGenericTypeDefinition)                 
       End Sub
    End Module
    ' The example displays the following output:
    '       Generic Class: Derived`1
    '          Contains Generic Paramters: True
    '          Generic Type Definition: True
    '       
    '       Its Base Class: (unassigned) Base`1[T]
    '          Contains Generic Paramters: True
    '          Generic Type Definition: False
    '          Full Name: Base`1
    '       
    '       Generic Class: Base`1
    '          Contains Generic Paramters: True
    '          Generic Type Definition: True
    

    이 아닌를 가져오려면 메서드를 사용 하 여 FullName null GetGenericTypeDefinition 예제에서 보여 주는 것 처럼 제네릭 형식 정의를 가져올 수 있습니다.

이 속성은 읽기 전용입니다.

적용 대상

추가 정보