TypeExtensionsGetReflectedTypeName Method
Gets a C#-compatible proper type name, resolving generic type names using reflection with no backticks (`), for the specified type.
Namespace: Gemstone.TypeExtensionsAssembly: 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
)
<ExtensionAttribute>
Public Shared Function GetReflectedTypeName (
type As Type,
Optional useNativeTypeNames As Boolean = true,
Optional includeNamespaces As Boolean = true
) As String
public:
[ExtensionAttribute]
static String^ GetReflectedTypeName(
Type^ type,
bool useNativeTypeNames = true,
bool includeNamespaces = true
)
Gemstone.TypeExtensions.TypeExtensions.GetReflectedTypeName = function(type, useNativeTypeNames, includeNamespaces);
- 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.
String
A C#-compatible proper type name, resolving generic type names using reflection with no backticks (`), for the specified
type.
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).
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.