Default value of a type

Posted by viky on Stack Overflow See other posts from Stack Overflow or by viky
Published on 2010-03-22T05:55:37Z Indexed on 2010/03/22 6:01 UTC
Read the original article Hit count: 257

Filed under:
|
|
|

For any given type i want to know its default value.

In C#, there is a keyword called default for doing this like

object obj = default(Decimal);

but I have an instance of Type (called myType) and if I say this,

object obj = default(myType);

it doesn't work

Is there any good way of doing this? I know that a huge switch block will work but thats not a good choice.

© Stack Overflow or respective owner

Related posts about c#

Related posts about type