Click or drag to resize

TypeExtensionMethodsGetDefaultValue Method

Gets the default value for the type, e.g. 0 for int, empty guid for guid.

Namespace:  SD.Tools.BCLExtensions.SystemRelated
Assembly:  SD.Tools.BCLExtensions (in SD.Tools.BCLExtensions.dll) Version: 1.2.0
Syntax
public static Object GetDefaultValue(
	this Type typeToCreateValueFor,
	bool safeDefaults
)

Parameters

typeToCreateValueFor
Type: SystemType
The type to create value for.
safeDefaults
Type: SystemBoolean
if set to true, the routine will return string.Empty for string and empty byte array for byte[], otherwise null

Return Value

Type: Object
the default value for the type. It returns string.Empty for string, empty byte array for a byte array, if safeDefaults is set to true

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).
See Also