如何通過值比較兩個值類型System.Object?如何通過值比較兩個System.Object類型的值?
如何做到以下幾點:
void Validate(Type t, Object obj)//t is always a Basic type like System.Int32, System.DateTime, System.String, etc.
{
Object value = Convert.ChangeType(obj, t);
Object minValue = Convert.ChangeType(this.MinValue.Value, t);
Object maxValue = Convert.ChangeType(this.MaxValue.Value, t);
if (!(minValue >= value && value >= maxValue))
{
throw new Exception(".....err...message.....");
}
}