Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ TryCreate< TOther >() [1/2]

static bool INumber< short >. System.Int16.TryCreate< TOther > ( TOther value,
out short result )
inlinestatic

Definition at line 751 of file Int16.cs.

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

References System.L, System.ThrowHelper.ThrowNotSupportedException(), and System.value.