如何通过反射得到某个ValueType的MinValue/MaxValue?

Dra*_*ake 4 .net vb.net reflection

我需要在运行时使用它.我使用Reflector检查了,例如Int16的值类型行应该包含

<Serializable, StructLayout(LayoutKind.Sequential), ComVisible(True)> _
Public Structure Int16
    Implements IComparable, IFormattable, IConvertible, IComparable(Of Short), IEquatable(Of Short)

Public Const MaxValue As Short = &H7FFF
Public Const MinValue As Short = -32768


End Structure
Run Code Online (Sandbox Code Playgroud)

但是以下代码不起作用

Dim dummyValue = Activator.CreateInstance(GetType(UInt16))
Dim minValue As IComparable =    DirectCast(dummyValue.GetType.GetProperty("MinValue").GetValue(dummyValue,
Nothing), IComparable)
Run Code Online (Sandbox Code Playgroud)

任何想法如何解决?

编辑:仅用于直接使用GetType(UInt16)的示例,但在实际代码中,此部分由设计时未知的实例.NET类型替换

M.A*_*nin 7

使用GetType.GetField("MinValue").常量被视为字段