/// <summary> /// Encode the given object as the given type. /// </summary> /// <param name="obj">The object to encode</param> /// <param name="type">the type of object it is or it is to be encoded as</param> /// <returns>Return an array of bytes representing the given object using the given type specification.</returns> /// <exception cref="ArgumentException">if the object cannot be encoded using that type</exception> public static byte[] Encode(object obj, byte type) { FieldType datatype = GetDataType(type); return(datatype.Encode(obj)); }