Foundation.NSNumber Class
Binding to Objective-C API to box numbers (value types).

See Also: NSNumber Members

Syntax

[Foundation.Register("NSNumber", true)]
public class NSNumber : NSValue, IComparable, IComparable<NSNumber>, IEquatable<NSNumber>

Remarks

NSNumber provides explicit operator conversions that allow you to cast an NSNumber into any of the core .NET types (float, double, int, uint, short, ushort, byte, sbyte and bool).

NSNumber also provides implicit operator conversions that allow you to create NSNumber instances from the core .NET types (float, double, int, uint, short, ushort, byte, sbyte and bool).

c# Example

// Creates an NSNumber that contains the integer value 4.
NSNumber d = 4;

// Obtains a float from an NSNumber using explicit casts:
float asFloat = (float) d;

// Passes a float to a method taking an NSNumber implicitly:
void RunForSeconds (NSNumber seconds)
{
...
}
[...]
RunForSeconds (4);
	

Related content

Requirements

Namespace: Foundation
Assembly: Xamarin.iOS (in Xamarin.iOS.dll)
Assembly Versions: 0.0.0.0