PeterO.Cbor.CBORObject.AsUInt16 C# (CSharp) Method

AsUInt16() private method

private AsUInt16 ( ) : ushort
return ushort
        public ushort AsUInt16()
        {
            int v = this.AsInt32();
              if (v > UInt16.MaxValue || v < 0) {
            throw new OverflowException("This object's value is out of range");
              }
              return (ushort)v;
        }

Usage Example

Example #1
0
 private static object TypeToIntegerObject(CBORObject objThis, Type t)
 {
     if (t.Equals(typeof(int)))
     {
         return(objThis.AsInt32());
     }
     if (t.Equals(typeof(short)))
     {
         return(objThis.AsInt16());
     }
     if (t.Equals(typeof(ushort)))
     {
         return(objThis.AsUInt16());
     }
     if (t.Equals(typeof(byte)))
     {
         return(objThis.AsByte());
     }
     if (t.Equals(typeof(sbyte)))
     {
         return(objThis.AsSByte());
     }
     if (t.Equals(typeof(long)))
     {
         return(objThis.AsInt64());
     }
     if (t.Equals(typeof(uint)))
     {
         return(objThis.AsUInt32());
     }
     if (t.Equals(typeof(ulong)))
     {
         return(objThis.AsUInt64());
     }
     throw new CBORException("Type not supported");
 }
All Usage Examples Of PeterO.Cbor.CBORObject::AsUInt16