Click or drag to resize

TypeExtensionsGetReflectedTypeName Method

Gets a C#-compatible proper type name, resolving generic type names using reflection with no backticks (`), for the specified type.

Namespace: GSF
Assembly: GSF.Core (in GSF.Core.dll) Version: 2.4.181-beta
Syntax
public static string GetReflectedTypeName(
	this Type type,
	bool includeNamespaces = true
)
View Source

Parameters

type  Type
The Type whose name is to be resolved.
includeNamespaces  Boolean  (Optional)
Flag that indicates if namespaces should be included in the type name.

Return Value

String
A C#-compatible proper type name, resolving generic type names using reflection with no backticks (`), for the specified type.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Type. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Remarks
This method will return a C#-compatible proper type name, resolving generic type names using reflection, which creates a valid, useable type name versus what FullName returns. For example, FullName will return something like: System.Collections.Generic.List`1[[System.String, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e] with a backtick (`) to indicate a generic type and noisy assembly info. Even Type.Name returns List`1 with a backtick (`). For the same type, this method would instead return: System.Collections.Generic.List<System.String> which is a valid, usable C# type name. You can also set the includeNamespaces parameter to false to remove namespaces from the type name, which yields: List<String> for the same example.
See Also