Export (0) Print
Expand All

JsonPrimitive Constructor

Initializes a new instance of a JsonPrimitive type with a common language runtime (CLR) type.

This member is overloaded. For complete information about this member, including syntax, usage, and examples, click a name in the overload list.

  Name Description
Public method JsonPrimitive(Boolean) Initializes a new instance of a JsonPrimitive type with a Boolean type.
Public method JsonPrimitive(Byte) Initializes a new instance of a JsonPrimitive type with a Byte type.
Public method JsonPrimitive(Char) Initializes a new instance of a JsonPrimitive type with a Char type.
Public method JsonPrimitive(DateTime) Initializes a new instance of a JsonPrimitive type with a DateTime type.
Public method JsonPrimitive(Decimal) Initializes a new instance of a JsonPrimitive type with a Decimal type.
Public method JsonPrimitive(Double) Initializes a new instance of a JsonPrimitive type with a Double type.
Public method JsonPrimitive(Guid) Initializes a new instance of a JsonPrimitive type with a Guid type.
Public method JsonPrimitive(Int16) Initializes a new instance of a JsonPrimitive type with a Int16 type.
Public method JsonPrimitive(Int32) Initializes a new instance of a JsonPrimitive type with a Int32 type.
Public method JsonPrimitive(Int64) Initializes a new instance of a JsonPrimitive type with a Int64 type.
Public method JsonPrimitive(SByte) Initializes a new instance of a JsonPrimitive type with a SByte type.
Public method JsonPrimitive(Single) Initializes a new instance of a JsonPrimitive type with a Single type.
Public method JsonPrimitive(String) Initializes a new instance of a JsonPrimitive type with a String type.
Public method JsonPrimitive(TimeSpan) Initializes a new instance of a JsonPrimitive type with a TimeSpan type.
Public method JsonPrimitive(UInt16) Initializes a new instance of a JsonPrimitive type with a UInt16 type.
Public method JsonPrimitive(UInt32) Initializes a new instance of a JsonPrimitive type with a UInt32 type.
Public method JsonPrimitive(UInt64) Initializes a new instance of a JsonPrimitive type with a UInt64 type.
Public method JsonPrimitive(Uri) Initializes a new instance of a JsonPrimitive type with a Uri type.
Top

Overloads are available for many common CLR types. A JsonPrimitive object maps the CLR type used to initialize it to a JsonType and stores this along with the value used to initialize it. The JsonType of the JsonPrimitive object can be recovered using the JsonType property. The value used to initialize the JsonPrimitive object can be recovered using the ToString() method.



            //Initialize JSON primitive with a decimal.
            decimal dNumber = new Decimal(42);
            JsonPrimitive jsonP1 = new JsonPrimitive(dNumber);

            //Initialize JSON primitive with a UInt32.
            System.UInt32 uInt32Number = 43;
            JsonPrimitive jsonP2 = new JsonPrimitive(uInt32Number);

            //Initialize JSON primitive with a DateTime.
            DateTime datetime = new DateTime(300);
            JsonPrimitive jsonP3 = new JsonPrimitive(datetime);

            //Initialize JSON primitive with a UInt16.
            System.UInt16 uInt16Number = 44;
            JsonPrimitive jsonP4 = new JsonPrimitive(uInt16Number);

            //Initialize JSON primitive with an Int16.
            System.UInt16 int16Number = 45;
            JsonPrimitive jsonP5 = new JsonPrimitive(int16Number);

            //Initialize JSON primitive with an GUID.
            Guid guid = new Guid();
            JsonPrimitive jsonP6 = new JsonPrimitive(guid);







            //Initialize JSON primitive with a bool.
            JsonPrimitive jsonP10 = new JsonPrimitive(true);



Community Additions

ADD
Show:
© 2014 Microsoft