A
Andrus
How to create method
object DefaultValue( Type valueType ) { ... }
Which returns defualt value for passed value type ?
DefaultValue(typeof(int))
DefaultValue(typeof(decimal))
should return 0
DefaultValue(typeof(bool))
should return false
etc.
I can use
if ( valuetype==typeof(int) )
return 0;
else
if ( valuetype==typeof(bool) )
return false;
etc.
but its looks ugly. Is there a better solution ?
Andrus.
object DefaultValue( Type valueType ) { ... }
Which returns defualt value for passed value type ?
DefaultValue(typeof(int))
DefaultValue(typeof(decimal))
should return 0
DefaultValue(typeof(bool))
should return false
etc.
I can use
if ( valuetype==typeof(int) )
return 0;
else
if ( valuetype==typeof(bool) )
return false;
etc.
but its looks ugly. Is there a better solution ?
Andrus.