746 {
747 if (typeof(TOther) == typeof(byte))
748 {
749 result = (byte)(
object)
value;
750 return true;
751 }
752 if (typeof(TOther) == typeof(char))
753 {
754 result = (char)(
object)
value;
755 return true;
756 }
757 if (typeof(TOther) == typeof(decimal))
758 {
759 decimal num = (decimal)(
object)
value;
760 if (num < 0m || num > 65535m)
761 {
762 result = 0;
763 return false;
764 }
765 result = (ushort)num;
766 return true;
767 }
768 if (typeof(TOther) == typeof(double))
769 {
770 double num2 = (double)(
object)
value;
771 if (num2 < 0.0 || num2 > 65535.0)
772 {
773 result = 0;
774 return false;
775 }
776 result = (ushort)num2;
777 return true;
778 }
779 if (typeof(TOther) == typeof(short))
780 {
782 if (num3 < 0)
783 {
784 result = 0;
785 return false;
786 }
787 result = (ushort)num3;
788 return true;
789 }
790 if (typeof(TOther) == typeof(int))
791 {
792 int num4 = (int)(
object)
value;
793 if (num4 < 0 || num4 > 65535)
794 {
795 result = 0;
796 return false;
797 }
798 result = (ushort)num4;
799 return true;
800 }
801 if (typeof(TOther) == typeof(long))
802 {
803 long num5 = (long)(
object)
value;
804 if (num5 < 0 || num5 > 65535)
805 {
806 result = 0;
807 return false;
808 }
809 result = (ushort)num5;
810 return true;
811 }
812 if (typeof(TOther) == typeof(IntPtr))
813 {
815 if ((nint)intPtr < 0 || (nint)intPtr > 65535)
816 {
817 result = 0;
818 return false;
819 }
820 result = (ushort)(nint)intPtr;
821 return true;
822 }
823 if (typeof(TOther) == typeof(sbyte))
824 {
825 sbyte b = (sbyte)(
object)
value;
826 if (b < 0)
827 {
828 result = 0;
829 return false;
830 }
831 result = (ushort)b;
832 return true;
833 }
834 if (typeof(TOther) == typeof(float))
835 {
836 float num6 = (float)(
object)
value;
837 if (num6 < 0f || num6 > 65535f)
838 {
839 result = 0;
840 return false;
841 }
842 result = (ushort)num6;
843 return true;
844 }
845 if (typeof(TOther) == typeof(ushort))
846 {
847 result = (ushort)(
object)
value;
848 return true;
849 }
850 if (typeof(TOther) == typeof(uint))
851 {
852 uint num7 = (uint)(
object)
value;
853 if (num7 > 65535)
854 {
855 result = 0;
856 return false;
857 }
858 result = (ushort)num7;
859 return true;
860 }
861 if (typeof(TOther) == typeof(ulong))
862 {
863 ulong num8 = (ulong)(
object)
value;
864 if (num8 > 65535)
865 {
866 result = 0;
867 return false;
868 }
869 result = (ushort)num8;
870 return true;
871 }
872 if (typeof(TOther) == typeof(UIntPtr))
873 {
875 if ((nuint)uIntPtr > 65535)
876 {
877 result = 0;
878 return false;
879 }
880 result = (ushort)(nuint)uIntPtr;
881 return true;
882 }
883 ThrowHelper.ThrowNotSupportedException();
884 result = 0;
885 return false;
886 }