다음을 통해 공유


JsonPrimitive Constructor

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Include Protected Members
Include Inherited Members

Include Silverlight Members
Include Silverlight for Windows Phone Members
Include XNA Framework Members

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.

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

Remarks

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.

Examples


            'Initialize JSON primitive with a decimal.
            Dim dNumber As New Decimal(42)
            Dim jsonP1 As New JsonPrimitive(dNumber)

            'Initialize JSON primitive with a UInt32.
            Dim uInt32Number As System.UInt32 = 43
            Dim jsonP2 As New JsonPrimitive(uInt32Number)

            'Initialize JSON primitive with a DateTime.
            Dim datetime As New DateTime(300)
            Dim jsonP3 As New JsonPrimitive(datetime)

            'Initialize JSON primitive with a UInt16.
            Dim uInt16Number As System.UInt16 = 44
            Dim jsonP4 As New JsonPrimitive(uInt16Number)

            'Initialize JSON primitive with an Int16.
            Dim int16Number As System.UInt16 = 45
            Dim jsonP5 As New JsonPrimitive(int16Number)

            'Initialize JSON primitive with an GUID.
            Dim guid As New Guid()
            Dim jsonP6 As New JsonPrimitive(guid)







            'Initialize JSON primitive with a bool.
            Dim jsonP10 As New JsonPrimitive(True)


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