I'm seeking for a solution in C#. I have a dictionary like
NSDictionary metrics = new NSDictionary ("leftInset", 22);
Now I want to get the number as float. I tried this
metrics.ValueForKey(new NSString("leftInset"))
but the return value is of type NSObject. How can I get the float?
float f = (metrics ["leftInset"] as NSNumber).FloatValue;
Cast it to an NSNumber.
NSDictionary:
There is a convenient constructor that takes at least one key and one value, with optional values that will create the dictionary by pairing each key with a value. If you use .NET objects, the keys and values will first be boxed into NSObjects using NSObject.FromObject.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With