503 {
504 if (typeof(TOther) == typeof(byte))
505 {
506 return (
byte)(object)
value;
507 }
508 if (typeof(TOther) == typeof(char))
509 {
510 return (
char)(object)
value;
511 }
512 if (typeof(TOther) == typeof(decimal))
513 {
514 decimal num = (decimal)(
object)
value;
515 if (!(num > 65535m))
516 {
517 if (!(num < 0m))
518 {
519 return (ushort)num;
520 }
521 return 0;
522 }
523 return ushort.MaxValue;
524 }
525 if (typeof(TOther) == typeof(double))
526 {
527 double num2 = (double)(
object)
value;
528 if (!(num2 > 65535.0))
529 {
530 if (!(num2 < 0.0))
531 {
532 return (ushort)num2;
533 }
534 return 0;
535 }
536 return ushort.MaxValue;
537 }
538 if (typeof(TOther) == typeof(short))
539 {
541 if (num3 >= 0)
542 {
543 return (ushort)num3;
544 }
545 return 0;
546 }
547 if (typeof(TOther) == typeof(int))
548 {
549 int num4 = (int)(
object)
value;
550 if (num4 <= 65535)
551 {
552 if (num4 >= 0)
553 {
554 return (ushort)num4;
555 }
556 return 0;
557 }
558 return ushort.MaxValue;
559 }
560 if (typeof(TOther) == typeof(long))
561 {
562 long num5 = (long)(
object)
value;
563 if (num5 <= 65535)
564 {
565 if (num5 >= 0)
566 {
567 return (ushort)num5;
568 }
569 return 0;
570 }
571 return ushort.MaxValue;
572 }
573 if (typeof(TOther) == typeof(IntPtr))
574 {
576 if ((nint)intPtr <= 65535)
577 {
578 if ((nint)intPtr >= 0)
579 {
580 return (ushort)(nint)intPtr;
581 }
582 return 0;
583 }
584 return ushort.MaxValue;
585 }
586 if (typeof(TOther) == typeof(sbyte))
587 {
588 sbyte b = (sbyte)(
object)
value;
589 if (b >= 0)
590 {
591 return (ushort)b;
592 }
593 return 0;
594 }
595 if (typeof(TOther) == typeof(float))
596 {
597 float num6 = (float)(
object)
value;
598 if (!(num6 > 65535f))
599 {
600 if (!(num6 < 0f))
601 {
602 return (ushort)num6;
603 }
604 return 0;
605 }
606 return ushort.MaxValue;
607 }
608 if (typeof(TOther) == typeof(ushort))
609 {
610 return (ushort)(object)
value;
611 }
612 if (typeof(TOther) == typeof(uint))
613 {
614 uint num7 = (uint)(
object)
value;
615 if (num7 <= 65535)
616 {
617 return (ushort)num7;
618 }
619 return ushort.MaxValue;
620 }
621 if (typeof(TOther) == typeof(ulong))
622 {
623 ulong num8 = (ulong)(
object)
value;
624 if (num8 <= 65535)
625 {
626 return (ushort)num8;
627 }
628 return ushort.MaxValue;
629 }
630 if (typeof(TOther) == typeof(UIntPtr))
631 {
633 if ((nuint)uIntPtr <= 65535)
634 {
635 return (ushort)(nuint)uIntPtr;
636 }
637 return ushort.MaxValue;
638 }
639 ThrowHelper.ThrowNotSupportedException();
640 return 0;
641 }