Mac Guides | Samples

MonoMac.Foundation.NSNumber Class

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

See Also: NSNumber

Syntax

[MonoMac.Foundation.Register("NSNumber", true)]
public class NSNumber : NSValue

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);

Requirements

Namespace: MonoMac.Foundation
Assembly: XamMac (in XamMac.dll)
Assembly Versions: 0.0.0.0

The members of MonoMac.Foundation.NSNumber are listed below.

See Also: NSValue

Public Constructors

A constructor that initializes the object from the data stored in the unarchiver object.
Constructor to call on derived classes when the derived class has an [Export] constructor.
A constructor used when creating managed representations of unmanaged objects; Called by the runtime.

Public Properties

[read-only]
BoolValueBoolean.
[read-only]
ByteValueByte.
[read-only]
override
ClassHandleIntPtr. The handle for this class.
[read-only]
DoubleValueDouble.
[read-only]
FloatValueSingle.
[read-only]
Int16ValueInt16.
[read-only]
Int32ValueInt32.
[read-only]
Int64ValueInt64.
[read-only]
IntValueInt32.
[read-only]
NSDecimalValueNSDecimal.
[read-only]
SByteValueSByte.
[read-only]
StringValueString.
[read-only]
UInt16ValueUInt16.
[read-only]
UInt32ValueUInt32.
[read-only]
UInt64ValueUInt64.
[read-only]
UnsignedIntegerValueUInt32.

Public Methods

Public Operators