GenericExtensionsGetDefaultValue Method

Returns the default value of a type during runtime.

Definition

Namespace: MobileTrack.Common.Extensions
Assembly: MobileTrack.Common (in MobileTrack.Common.dll) Version: 0.7+45c8d9adb5970d727cceec44a5ed61aea0016e50
public static Object? GetDefaultValue(
	this Type type
)

Parameters

type  Type
Type to receive the default value for.

Return Value

Object
Default value ( for classes)

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

CreateInstance(String, String) does not make the cut here, as C# 10 and later allow one to use .
We also only call GetUninitializedObject(Type) only if type is a value type; if we were to call it for a class, it would not return .

See Also