Click or drag to resize

ExtensionsReflectionGetDefaultInstance Method

Retrieves the default value for a given Type.

http://stackoverflow.com/questions/2490244/default-value-of-a-type-at-runtime By Mark Jones

Namespace:  Cauldron
Assembly:  Cauldron.Activator (in Cauldron.Activator.dll) Version: 3.2.0.1 (3.2.0.1)
Syntax
C#
public static Object GetDefaultInstance(
	this Type type
)

Parameters

type
Type: SystemType
The Type for which to get the default value

Return Value

Type: Object
The default value for 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
If a null Type, a reference Type, or a System.Void Type is supplied, this method always returns null. If a value type is supplied which is not publicly visible or which contains generic parameters, this method will fail with an exception.
See Also