How to know default value of Type

In generic approach I can use default keyword to know what is default value

public T GetDefaultValue<T>()
{
return default(T);
}

But if only has a System.Type, I can't use default keyword to do it....

public object GetDefaultValue(System.Type dataType)
{
return default(dataType); //Not work....Tongue Tied
}

Please helpTongue TiedTongue Tied

[557 byte] By [EagleTsui] at [2008-2-5]
# 1

There's no way to do this in C# 2.0.

The workaround is cumbersome - from the type, you can instantiate an object (using TypeDescriptor.CreateInstance) with zero arguments. That will create a new object with default value. Now, you can return that object.

VijayeRaji at 2007-8-21 > top of Msdn Tech,Visual C#,Visual C# Language...
# 2
What's defferent between Activator.CreateInstance and TypeDescriptor.CreateInstance
EagleTsui at 2007-8-21 > top of Msdn Tech,Visual C#,Visual C# Language...
# 3
My bad. The appropriate method to use here is Activator.CreateInstance. I believe TypeDescriptor.CreateInstance will create an instance of a substitution type - as specified by a TypeDescriptionProvider.
VijayeRaji at 2007-8-21 > top of Msdn Tech,Visual C#,Visual C# Language...