我有一个NSObject,可能是NSDecimal或NSDecimalNumber。如果是,我想将其转换为C#十进制值。我怎么能这样做?
if (o is NSDecimalNumber) {
var dn = (NSDecimalNumber)o;
return (decimal)(Somehow(dn));
}
if (o is NSDecimal) {
var d = (NSDecimal)o;
return (decimal)(Somehow(d));
}
答案 0 :(得分:0)
if (o is NSDecimalNumber || o is NSDecimal) {
return decimal.Parse (o.ToString (), CultureInfo.InvariantCulture);
}