TypeExtensionsGetReflectedTypeName Method

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

Definition

Namespace: Gemstone.TypeExtensions
Assembly: Gemstone.Common (in Gemstone.Common.dll) Version: 1.0.128 -- Release Build+d050cfc5563c89a1188cc3c6b2d417530856f490
public static string GetReflectedTypeName(
	this Type type,
	bool useNativeTypeNames = true,
	bool includeNamespaces = true
)

Parameters

type  Type
The Type whose name is to be resolved.
useNativeTypeNames  Boolean  (Optional)
Flag that indicates if native C# type names should be used, when possible.
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, usable 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