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

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

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

Definition at line 699 of file Int64.cs.

700 {
701 if (typeof(TOther) == typeof(byte))
702 {
703 result = (byte)(object)value;
704 return true;
705 }
706 if (typeof(TOther) == typeof(char))
707 {
708 result = (char)(object)value;
709 return true;
710 }
711 if (typeof(TOther) == typeof(decimal))
712 {
713 decimal num = (decimal)(object)value;
714 if (num < -9223372036854775808m || num > 9223372036854775807m)
715 {
716 result = 0L;
717 return false;
718 }
719 result = (long)num;
720 return true;
721 }
722 if (typeof(TOther) == typeof(double))
723 {
724 double num2 = (double)(object)value;
725 if (num2 < -9.223372036854776E+18 || num2 > 9.223372036854776E+18)
726 {
727 result = 0L;
728 return false;
729 }
730 result = (long)num2;
731 return true;
732 }
733 if (typeof(TOther) == typeof(short))
734 {
735 result = (short)(object)value;
736 return true;
737 }
738 if (typeof(TOther) == typeof(int))
739 {
740 result = (int)(object)value;
741 return true;
742 }
743 if (typeof(TOther) == typeof(long))
744 {
745 result = (long)(object)value;
746 return true;
747 }
748 if (typeof(TOther) == typeof(IntPtr))
749 {
750 result = (long)(IntPtr)(object)value;
751 return true;
752 }
753 if (typeof(TOther) == typeof(sbyte))
754 {
755 result = (sbyte)(object)value;
756 return true;
757 }
758 if (typeof(TOther) == typeof(float))
759 {
760 float num3 = (float)(object)value;
761 if (num3 < -9.223372E+18f || num3 > 9.223372E+18f)
762 {
763 result = 0L;
764 return false;
765 }
766 result = (long)num3;
767 return true;
768 }
769 if (typeof(TOther) == typeof(ushort))
770 {
771 result = (ushort)(object)value;
772 return true;
773 }
774 if (typeof(TOther) == typeof(uint))
775 {
776 result = (uint)(object)value;
777 return true;
778 }
779 if (typeof(TOther) == typeof(ulong))
780 {
781 ulong num4 = (ulong)(object)value;
782 if (num4 > long.MaxValue)
783 {
784 result = 0L;
785 return false;
786 }
787 result = (long)num4;
788 return true;
789 }
790 if (typeof(TOther) == typeof(UIntPtr))
791 {
792 UIntPtr uIntPtr = (UIntPtr)(object)value;
793 if ((ulong)(nuint)uIntPtr > 9223372036854775807uL)
794 {
795 result = 0L;
796 return false;
797 }
798 result = (long)(nuint)uIntPtr;
799 return true;
800 }
801 ThrowHelper.ThrowNotSupportedException();
802 result = 0L;
803 return false;
804 }
const long MaxValue
Definition Int64.cs:15

References System.E, System.L, System.Int64.MaxValue, System.ThrowHelper.ThrowNotSupportedException(), and System.value.