从 NSDictionary 中获取浮点值

tes*_*ing 3 c# floating-point xamarin.ios ios xamarin

我正在寻求解决方案C#。我有一本像

NSDictionary metrics = new NSDictionary ("leftInset", 22);
Run Code Online (Sandbox Code Playgroud)

现在我想将数字作为float. 我试过这个

metrics.ValueForKey(new NSString("leftInset"))
Run Code Online (Sandbox Code Playgroud)

但返回值的类型是NSObject。我怎样才能得到浮点数?

pou*_*pou 5

float f = (metrics ["leftInset"] as NSNumber).FloatValue;
Run Code Online (Sandbox Code Playgroud)