Type.FullName Özellik
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Ad alanı dahil ancak derlemesi dahil olmak üzere türün tam adını alır.
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
Özellik Değeri
Ad alanı dahil ancak derlemesi dahil olmak üzere türün tam adı; veya null türü tam adla temsil edilemiyorsa. Tam adla temsil edilemeyen türler, çözümlenmemiş genel parametreler (ContainsGenericParameters is true) içeren türleri ve işlev işaretçileri içeren türleri içerir.
Uygulamalar
Örnekler
Aşağıdaki örnek, belirtilen türün tam adını görüntüler.
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.
*/
open System
let t = typeof<Array>
printfn $"The full name of the Array type is {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.
'
Aşağıdaki örnek, yöntemi tarafından ToString döndürülen dizeleri ve Name, FullNameve AssemblyQualifiedName özelliklerini karşılaştırır.
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
open System
open System.Globalization
let showTypeInfo (t: Type) =
printfn $"Name: {t.Name}"
printfn $"Full Name: {t.FullName}"
printfn $"ToString: {t}"
printfn $"Assembly Qualified Name: {t.AssemblyQualifiedName}\n"
typeof<String>
|> showTypeInfo
(typeof<ResizeArray<_>>).GetGenericTypeDefinition()
|> showTypeInfo
let list = ResizeArray<String>()
list.GetType()
|> showTypeInfo
let v: obj = 12
v.GetType()
|> showTypeInfo
typeof<IFormatProvider>
|> showTypeInfo
let ifmt = NumberFormatInfo.CurrentInfo
ifmt.GetType()
|> showTypeInfo
let o = Some 3
o.GetType()
|> showTypeInfo
// 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
//
// Name: FSharpOption`1
// Full Name: Microsoft.FSharp.Core.FSharpOption`1[[System.Int32, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]
// ToString: Microsoft.FSharp.Core.FSharpOption`1[System.Int32]
// Assembly Qualified Name: Microsoft.FSharp.Core.FSharpOption`1[[System.Int32, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], FSharp.Core, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
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
Açıklamalar
Örneğin, türün tam adı String şeklindedir System.String. Bunu, tam adın yanı sıra tam derleme adından AssemblyQualifiedName oluşan özelliği tarafından döndürülen derleme nitelikli adıyla karşıtlık edin.
Geçerli tür kapalı bir genel türü temsil ediyorsa, özelliği tarafından FullName döndürülen dizedeki tür bağımsız değişkenleri, genel türün dize gösterimi tam derleme adıyla nitelenmese bile tam derleme adıyla nitelenir. Aşağıdaki örnekte, genel tür tanımını temsil eden bir türün FullName özelliğindeki fark ve kapalı bir genel türü temsil eden bir tür gösterilmektedir.
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]]
// ResizeArray<'T> is an F# type abbreviation for System.Collection.Generic.List<'T>
open System
let t = typeof<ResizeArray<_>>.GetGenericTypeDefinition()
printfn $"{t.FullName}"
Console.WriteLine()
let list = ResizeArray<String>()
let t2 = list.GetType()
printfn $"{t2.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]]
Bu özellik şu durumda döndürür null :
Geçerli Type nesne, genel bir türün tür parametresini temsil eder.
Aşağıdaki örnek türün tür parametresini Nullable<T> alır ve özelliğini görüntülemeye FullName çalışır.
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) Topen System let t = typeof<Nullable<_>>.GetGenericTypeDefinition() printfn $"{t.FullName}" if t.IsGenericType then printf " Generic Type Parameters: " let gtArgs = t.GetGenericArguments() for arg in gtArgs do match arg.FullName with | null -> "(unassigned) " + string arg | _ -> arg.FullName |> printfn "%s" printfn "" // The example displays the following output: // System.Nullable`1 // Generic Type Parameters: (unassigned) TImports 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) TGeçerli Type nesne bir dizi türünü, işaretçi türünü veya genel tür
byrefparametresini temel alan bir türü temsil eder.Aşağıdaki örnek,
Generictype1<T>üç yöntemle genel bir türü tanımlar:Display(T[]), T türünde bir dizi geçirilir;HandleT(T)T nesnesi geçirilir; veChangeValue(ref T)T nesnesi başvuruyla geçirilir. C# ve Visual Basic yöntemindeHandleTbir işaretçi olarak T tanımlamamıza izin vermediğinden, genel bir türe işaretçi oluşturmak için yöntemin parametre türünü temsil eden nesnede Type yöntemini çağırmamız MakePointerType gerekir. Örnekteki çıktı, üç durumda da özelliğinin FullName olduğununullgösterir.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)open System.Reflection type GenericType1<'T>() = member _.Display(elements: 'T[]) = () member _.HandleT(obj: 'T) = () member _.ChangeValue(arg: 'T byref) = true let t = typeof<GenericType1<_>>.GetGenericTypeDefinition() printfn $"Type Name: {t.FullName}" let methods = t.GetMethods(BindingFlags.Instance ||| BindingFlags.DeclaredOnly ||| BindingFlags.Public) for method in methods do printfn $" Method: {method.Name}" // Get method parameters. let param = method.GetParameters()[0] let paramType = param.ParameterType if method.Name = "HandleT" then let paramType = paramType.MakePointerType() match paramType.FullName with | null -> string paramType + " (unassigned)" | _ -> paramType.FullName |> printfn " Parameter: %s" // 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)Geçerli tür, belirli türlerle değiştirilmemiş genel tür parametreleri içerir (yani, ContainsGenericParameters özellik döndürür
true), ancak tür genel tür tanımı değildir (yani, özellik döndürür)IsGenericTypeDefinitionfalseAşağıdaki örnekte,
Derived<T>öğesindenBase<T>devralır. BaseType özelliği, temel türünüDerived<T>temsil eden nesnesini alır Type ve FullName özelliği döndürürnull.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: Truetype Base<'T>() = class end type Derived<'T>() = inherit Base<'T>() let t = typeof<Derived<_>>.GetGenericTypeDefinition() printfn $"Generic Class: {t.FullName}" printfn $" Contains Generic Paramters: {t.ContainsGenericParameters}" printfn $" Generic Type Definition: {t.IsGenericTypeDefinition}\n" let baseType = t.BaseType match baseType.FullName with | null -> "(unassigned) " + string baseType | _ -> baseType.FullName |> printfn "Its Base Class: %s" printfn $" Contains Generic Paramters: {baseType.ContainsGenericParameters}" printfn $" Generic Type Definition: {baseType.IsGenericTypeDefinition}" printfn $" Full Name: {baseType.GetGenericTypeDefinition().FullName}\n" let t2 = typeof<Base<_>>.GetGenericTypeDefinition() printfn $"Generic Class: {t2.FullName}" printfn $" Contains Generic Paramters: {t2.ContainsGenericParameters}" printfn $" Generic Type Definition: {t2.IsGenericTypeDefinition}\n" // 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: TrueImports 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: Trueolmayan
nullbir FullName almak için, örnekte gösterildiği gibi genel tür tanımını almak için yöntemini kullanabilirsinizGetGenericTypeDefinition.
Bu özellik salt okunurdur.