Andrus <ko********@hot.eewrote:
My type contains constructor with nullable parameter like
public class Iandmed {
public Iandmed(DateTime? miskuup) {}
}
I tried to get its constructor parameter type name using
Type t = typeof(Iandmed);
ConstructorInfo c = t.GetConstructors()[0];
ParameterInfo p = c.GetParameters()[0];
p.ParameterType.Name returns wrong values for nullable types, in this case
"Nullable`1"
How to get exact type name:
"DateTime?"
Don't use the Name property - use other properties to get specific
parts. In particular, the FullName property gives
System.Nullable`1[[System.DateTime, mscorlib, Version=2.0.0.0,
Culture=neutral,PublicKeyToken=b77a5c561934e089]]
Alternatively you can use
p.ParameterType.GetGenericArguments()[0]
to get the DateTime part on its own, or
Nullable.GetUnderlyingType(p.ParameterType)
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog:
http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too