Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
Int32.cs
Go to the documentation of this file.
6
7namespace System;
8
10[TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
12{
13 private readonly int m_value;
14
15 public const int MaxValue = 2147483647;
16
17 public const int MinValue = -2147483648;
18
19 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
21
22 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
23 static int IMinMaxValue<int>.MinValue => int.MinValue;
24
25 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
26 static int IMinMaxValue<int>.MaxValue => int.MaxValue;
27
28 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
30
31 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
32 static int INumber<int>.One => 1;
33
34 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
35 static int INumber<int>.Zero => 0;
36
37 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
39
40 public int CompareTo(object? value)
41 {
42 if (value == null)
43 {
44 return 1;
45 }
46 if (value is int num)
47 {
48 if (this < num)
49 {
50 return -1;
51 }
52 if (this > num)
53 {
54 return 1;
55 }
56 return 0;
57 }
59 }
60
61 public int CompareTo(int value)
62 {
63 if (this < value)
64 {
65 return -1;
66 }
67 if (this > value)
68 {
69 return 1;
70 }
71 return 0;
72 }
73
74 public override bool Equals([NotNullWhen(true)] object? obj)
75 {
76 if (!(obj is int))
77 {
78 return false;
79 }
80 return this == (int)obj;
81 }
82
83 [NonVersionable]
84 public bool Equals(int obj)
85 {
86 return this == obj;
87 }
88
89 public override int GetHashCode()
90 {
91 return this;
92 }
93
94 public override string ToString()
95 {
96 return Number.Int32ToDecStr(this);
97 }
98
99 public string ToString(string? format)
100 {
101 return ToString(format, null);
102 }
103
104 public string ToString(IFormatProvider? provider)
105 {
106 return Number.FormatInt32(this, 0, null, provider);
107 }
108
109 public string ToString(string? format, IFormatProvider? provider)
110 {
111 return Number.FormatInt32(this, -1, format, provider);
112 }
113
114 public bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format = default(ReadOnlySpan<char>), IFormatProvider? provider = null)
115 {
116 return Number.TryFormatInt32(this, -1, format, provider, destination, out charsWritten);
117 }
118
119 public static int Parse(string s)
120 {
121 if (s == null)
122 {
124 }
126 }
127
128 public static int Parse(string s, NumberStyles style)
129 {
131 if (s == null)
132 {
134 }
136 }
137
138 public static int Parse(string s, IFormatProvider? provider)
139 {
140 if (s == null)
141 {
143 }
144 return Number.ParseInt32(s, NumberStyles.Integer, NumberFormatInfo.GetInstance(provider));
145 }
146
147 public static int Parse(string s, NumberStyles style, IFormatProvider? provider)
148 {
150 if (s == null)
151 {
153 }
154 return Number.ParseInt32(s, style, NumberFormatInfo.GetInstance(provider));
155 }
156
157 public static int Parse(ReadOnlySpan<char> s, NumberStyles style = NumberStyles.Integer, IFormatProvider? provider = null)
158 {
160 return Number.ParseInt32(s, style, NumberFormatInfo.GetInstance(provider));
161 }
162
163 public static bool TryParse([NotNullWhen(true)] string? s, out int result)
164 {
165 if (s == null)
166 {
167 result = 0;
168 return false;
169 }
171 }
172
173 public static bool TryParse(ReadOnlySpan<char> s, out int result)
174 {
176 }
177
178 public static bool TryParse([NotNullWhen(true)] string? s, NumberStyles style, IFormatProvider? provider, out int result)
179 {
181 if (s == null)
182 {
183 result = 0;
184 return false;
185 }
186 return Number.TryParseInt32(s, style, NumberFormatInfo.GetInstance(provider), out result) == Number.ParsingStatus.OK;
187 }
188
189 public static bool TryParse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider? provider, out int result)
190 {
192 return Number.TryParseInt32(s, style, NumberFormatInfo.GetInstance(provider), out result) == Number.ParsingStatus.OK;
193 }
194
196 {
197 return TypeCode.Int32;
198 }
199
201 {
202 return Convert.ToBoolean(this);
203 }
204
206 {
207 return Convert.ToChar(this);
208 }
209
211 {
212 return Convert.ToSByte(this);
213 }
214
216 {
217 return Convert.ToByte(this);
218 }
219
221 {
222 return Convert.ToInt16(this);
223 }
224
226 {
227 return Convert.ToUInt16(this);
228 }
229
231 {
232 return this;
233 }
234
236 {
237 return Convert.ToUInt32(this);
238 }
239
241 {
242 return Convert.ToInt64(this);
243 }
244
246 {
247 return Convert.ToUInt64(this);
248 }
249
251 {
252 return Convert.ToSingle(this);
253 }
254
256 {
257 return Convert.ToDouble(this);
258 }
259
261 {
262 return Convert.ToDecimal(this);
263 }
264
266 {
267 throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Int32", "DateTime"));
268 }
269
271 {
272 return Convert.DefaultToType(this, type, provider);
273 }
274
275 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
276 static int IAdditionOperators<int, int, int>.operator +(int left, int right)
277 {
278 return left + right;
279 }
280
281 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
283 {
285 }
286
287 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
289 {
290 return BitOperations.PopCount((uint)value);
291 }
292
293 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
294 static int IBinaryInteger<int>.RotateLeft(int value, int rotateAmount)
295 {
296 return (int)BitOperations.RotateLeft((uint)value, rotateAmount);
297 }
298
299 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
300 static int IBinaryInteger<int>.RotateRight(int value, int rotateAmount)
301 {
302 return (int)BitOperations.RotateRight((uint)value, rotateAmount);
303 }
304
305 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
310
311 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
313 {
314 return BitOperations.IsPow2(value);
315 }
316
317 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
319 {
320 if (value < 0)
321 {
323 }
324 return BitOperations.Log2((uint)value);
325 }
326
327 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
328 static int IBitwiseOperators<int, int, int>.operator &(int left, int right)
329 {
330 return left & right;
331 }
332
333 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
334 static int IBitwiseOperators<int, int, int>.operator |(int left, int right)
335 {
336 return left | right;
337 }
338
339 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
340 static int IBitwiseOperators<int, int, int>.operator ^(int left, int right)
341 {
342 return left ^ right;
343 }
344
345 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
346 static int IBitwiseOperators<int, int, int>.operator ~(int value)
347 {
348 return ~value;
349 }
350
351 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
352 static bool IComparisonOperators<int, int>.operator <(int left, int right)
353 {
354 return left < right;
355 }
356
357 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
358 static bool IComparisonOperators<int, int>.operator <=(int left, int right)
359 {
360 return left <= right;
361 }
362
363 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
364 static bool IComparisonOperators<int, int>.operator >(int left, int right)
365 {
366 return left > right;
367 }
368
369 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
370 static bool IComparisonOperators<int, int>.operator >=(int left, int right)
371 {
372 return left >= right;
373 }
374
375 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
376 static int IDecrementOperators<int>.operator --(int value)
377 {
378 return --value;
379 }
380
381 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
382 static int IDivisionOperators<int, int, int>.operator /(int left, int right)
383 {
384 return left / right;
385 }
386
387 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
388 static bool IEqualityOperators<int, int>.operator ==(int left, int right)
389 {
390 return left == right;
391 }
392
393 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
394 static bool IEqualityOperators<int, int>.operator !=(int left, int right)
395 {
396 return left != right;
397 }
398
399 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
400 static int IIncrementOperators<int>.operator ++(int value)
401 {
402 return ++value;
403 }
404
405 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
406 static int IModulusOperators<int, int, int>.operator %(int left, int right)
407 {
408 return left % right;
409 }
410
411 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
412 static int IMultiplyOperators<int, int, int>.operator *(int left, int right)
413 {
414 return left * right;
415 }
416
417 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
418 static int INumber<int>.Abs(int value)
419 {
420 return Math.Abs(value);
421 }
422
423 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
424 static int INumber<int>.Clamp(int value, int min, int max)
425 {
426 return Math.Clamp(value, min, max);
427 }
428
429 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
430 internal static int Create<TOther>(TOther value) where TOther : INumber<TOther>
431 {
432 if (typeof(TOther) == typeof(byte))
433 {
434 return (byte)(object)value;
435 }
436 if (typeof(TOther) == typeof(char))
437 {
438 return (char)(object)value;
439 }
440 if (typeof(TOther) == typeof(decimal))
441 {
442 return (int)(decimal)(object)value;
443 }
444 checked
445 {
446 if (typeof(TOther) == typeof(double))
447 {
448 return (int)(double)(object)value;
449 }
450 if (typeof(TOther) == typeof(short))
451 {
452 return (short)(object)value;
453 }
454 if (typeof(TOther) == typeof(int))
455 {
456 return (int)(object)value;
457 }
458 if (typeof(TOther) == typeof(long))
459 {
460 return (int)(long)(object)value;
461 }
462 if (typeof(TOther) == typeof(IntPtr))
463 {
464 return (int)(IntPtr)(object)value;
465 }
466 if (typeof(TOther) == typeof(sbyte))
467 {
468 return (sbyte)(object)value;
469 }
470 if (typeof(TOther) == typeof(float))
471 {
472 return (int)(float)(object)value;
473 }
474 if (typeof(TOther) == typeof(ushort))
475 {
476 return (ushort)(object)value;
477 }
478 if (typeof(TOther) == typeof(uint))
479 {
480 return (int)(uint)(object)value;
481 }
482 if (typeof(TOther) == typeof(ulong))
483 {
484 return (int)(ulong)(object)value;
485 }
486 if (typeof(TOther) == typeof(UIntPtr))
487 {
488 return (int)(nuint)(UIntPtr)(object)value;
489 }
491 return 0;
492 }
493 }
494
495 [MethodImpl(MethodImplOptions.AggressiveInlining)]
496 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
497 static int INumber<int>.Create<TOther>(TOther value)
498 {
499 return Create(value);
500 }
501
502 [MethodImpl(MethodImplOptions.AggressiveInlining)]
503 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
504 static int INumber<int>.CreateSaturating<TOther>(TOther value)
505 {
506 if (typeof(TOther) == typeof(byte))
507 {
508 return (byte)(object)value;
509 }
510 if (typeof(TOther) == typeof(char))
511 {
512 return (char)(object)value;
513 }
514 if (typeof(TOther) == typeof(decimal))
515 {
516 decimal num = (decimal)(object)value;
517 if (!(num > 2147483647m))
518 {
519 if (!(num < -2147483648m))
520 {
521 return (int)num;
522 }
523 return int.MinValue;
524 }
525 return int.MaxValue;
526 }
527 if (typeof(TOther) == typeof(double))
528 {
529 double num2 = (double)(object)value;
530 if (!(num2 > 2147483647.0))
531 {
532 if (!(num2 < -2147483648.0))
533 {
534 return (int)num2;
535 }
536 return int.MinValue;
537 }
538 return int.MaxValue;
539 }
540 if (typeof(TOther) == typeof(short))
541 {
542 return (short)(object)value;
543 }
544 if (typeof(TOther) == typeof(int))
545 {
546 return (int)(object)value;
547 }
548 if (typeof(TOther) == typeof(long))
549 {
550 long num3 = (long)(object)value;
551 if (num3 <= int.MaxValue)
552 {
553 if (num3 >= int.MinValue)
554 {
555 return (int)num3;
556 }
557 return int.MinValue;
558 }
559 return int.MaxValue;
560 }
561 if (typeof(TOther) == typeof(IntPtr))
562 {
563 IntPtr intPtr = (IntPtr)(object)value;
564 if ((nint)intPtr <= int.MaxValue)
565 {
566 if ((nint)intPtr >= int.MinValue)
567 {
568 return (int)(nint)intPtr;
569 }
570 return int.MinValue;
571 }
572 return int.MaxValue;
573 }
574 if (typeof(TOther) == typeof(sbyte))
575 {
576 return (sbyte)(object)value;
577 }
578 if (typeof(TOther) == typeof(float))
579 {
580 float num4 = (float)(object)value;
581 if (!(num4 > 2.1474836E+09f))
582 {
583 if (!(num4 < -2.1474836E+09f))
584 {
585 return (int)num4;
586 }
587 return int.MinValue;
588 }
589 return int.MaxValue;
590 }
591 if (typeof(TOther) == typeof(ushort))
592 {
593 return (ushort)(object)value;
594 }
595 if (typeof(TOther) == typeof(uint))
596 {
597 uint num5 = (uint)(object)value;
598 if (num5 <= int.MaxValue)
599 {
600 return (int)num5;
601 }
602 return int.MaxValue;
603 }
604 if (typeof(TOther) == typeof(ulong))
605 {
606 ulong num6 = (ulong)(object)value;
607 if (num6 <= int.MaxValue)
608 {
609 return (int)num6;
610 }
611 return int.MaxValue;
612 }
613 if (typeof(TOther) == typeof(UIntPtr))
614 {
615 UIntPtr uIntPtr = (UIntPtr)(object)value;
616 if ((nuint)uIntPtr <= int.MaxValue)
617 {
618 return (int)(nuint)uIntPtr;
619 }
620 return int.MaxValue;
621 }
623 return 0;
624 }
625
626 [MethodImpl(MethodImplOptions.AggressiveInlining)]
627 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
628 static int INumber<int>.CreateTruncating<TOther>(TOther value)
629 {
630 if (typeof(TOther) == typeof(byte))
631 {
632 return (byte)(object)value;
633 }
634 if (typeof(TOther) == typeof(char))
635 {
636 return (char)(object)value;
637 }
638 if (typeof(TOther) == typeof(decimal))
639 {
640 return (int)(decimal)(object)value;
641 }
642 if (typeof(TOther) == typeof(double))
643 {
644 return (int)(double)(object)value;
645 }
646 if (typeof(TOther) == typeof(short))
647 {
648 return (short)(object)value;
649 }
650 if (typeof(TOther) == typeof(int))
651 {
652 return (int)(object)value;
653 }
654 if (typeof(TOther) == typeof(long))
655 {
656 return (int)(long)(object)value;
657 }
658 if (typeof(TOther) == typeof(IntPtr))
659 {
660 return (int)(nint)(IntPtr)(object)value;
661 }
662 if (typeof(TOther) == typeof(sbyte))
663 {
664 return (sbyte)(object)value;
665 }
666 if (typeof(TOther) == typeof(float))
667 {
668 return (int)(float)(object)value;
669 }
670 if (typeof(TOther) == typeof(ushort))
671 {
672 return (ushort)(object)value;
673 }
674 if (typeof(TOther) == typeof(uint))
675 {
676 return (int)(uint)(object)value;
677 }
678 if (typeof(TOther) == typeof(ulong))
679 {
680 return (int)(ulong)(object)value;
681 }
682 if (typeof(TOther) == typeof(UIntPtr))
683 {
684 return (int)(nuint)(UIntPtr)(object)value;
685 }
687 return 0;
688 }
689
690 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
691 static (int Quotient, int Remainder) INumber<int>.DivRem(int left, int right)
692 {
693 return Math.DivRem(left, right);
694 }
695
696 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
697 static int INumber<int>.Max(int x, int y)
698 {
699 return Math.Max(x, y);
700 }
701
702 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
703 static int INumber<int>.Min(int x, int y)
704 {
705 return Math.Min(x, y);
706 }
707
708 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
709 static int INumber<int>.Parse(string s, NumberStyles style, IFormatProvider provider)
710 {
711 return Parse(s, style, provider);
712 }
713
714 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
716 {
717 return Parse(s, style, provider);
718 }
719
720 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
721 static int INumber<int>.Sign(int value)
722 {
723 return Math.Sign(value);
724 }
725
726 [MethodImpl(MethodImplOptions.AggressiveInlining)]
727 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
728 static bool INumber<int>.TryCreate<TOther>(TOther value, out int result)
729 {
730 if (typeof(TOther) == typeof(byte))
731 {
732 result = (byte)(object)value;
733 return true;
734 }
735 if (typeof(TOther) == typeof(char))
736 {
737 result = (char)(object)value;
738 return true;
739 }
740 if (typeof(TOther) == typeof(decimal))
741 {
742 decimal num = (decimal)(object)value;
743 if (num < -2147483648m || num > 2147483647m)
744 {
745 result = 0;
746 return false;
747 }
748 result = (int)num;
749 return true;
750 }
751 if (typeof(TOther) == typeof(double))
752 {
753 double num2 = (double)(object)value;
754 if (num2 < -2147483648.0 || num2 > 2147483647.0)
755 {
756 result = 0;
757 return false;
758 }
759 result = (int)num2;
760 return true;
761 }
762 if (typeof(TOther) == typeof(short))
763 {
764 result = (short)(object)value;
765 return true;
766 }
767 if (typeof(TOther) == typeof(int))
768 {
769 result = (int)(object)value;
770 return true;
771 }
772 if (typeof(TOther) == typeof(long))
773 {
774 long num3 = (long)(object)value;
775 if (num3 < int.MinValue || num3 > int.MaxValue)
776 {
777 result = 0;
778 return false;
779 }
780 result = (int)num3;
781 return true;
782 }
783 if (typeof(TOther) == typeof(IntPtr))
784 {
785 IntPtr intPtr = (IntPtr)(object)value;
786 if ((nint)intPtr < int.MinValue || (nint)intPtr > int.MaxValue)
787 {
788 result = 0;
789 return false;
790 }
791 result = (int)(nint)intPtr;
792 return true;
793 }
794 if (typeof(TOther) == typeof(sbyte))
795 {
796 result = (sbyte)(object)value;
797 return true;
798 }
799 if (typeof(TOther) == typeof(float))
800 {
801 float num4 = (float)(object)value;
802 if (num4 < -2.1474836E+09f || num4 > 2.1474836E+09f)
803 {
804 result = 0;
805 return false;
806 }
807 result = (int)num4;
808 return true;
809 }
810 if (typeof(TOther) == typeof(ushort))
811 {
812 result = (ushort)(object)value;
813 return true;
814 }
815 if (typeof(TOther) == typeof(uint))
816 {
817 uint num5 = (uint)(object)value;
818 if (num5 > int.MaxValue)
819 {
820 result = 0;
821 return false;
822 }
823 result = (int)num5;
824 return true;
825 }
826 if (typeof(TOther) == typeof(ulong))
827 {
828 ulong num6 = (ulong)(object)value;
829 if (num6 > int.MaxValue)
830 {
831 result = 0;
832 return false;
833 }
834 result = (int)num6;
835 return true;
836 }
837 if (typeof(TOther) == typeof(UIntPtr))
838 {
839 UIntPtr uIntPtr = (UIntPtr)(object)value;
840 if ((nuint)uIntPtr > int.MaxValue)
841 {
842 result = 0;
843 return false;
844 }
845 result = (int)(nuint)uIntPtr;
846 return true;
847 }
849 result = 0;
850 return false;
851 }
852
853 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
854 static bool INumber<int>.TryParse([NotNullWhen(true)] string s, NumberStyles style, IFormatProvider provider, out int result)
855 {
856 return TryParse(s, style, provider, out result);
857 }
858
859 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
860 static bool INumber<int>.TryParse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider provider, out int result)
861 {
862 return TryParse(s, style, provider, out result);
863 }
864
865 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
866 static int IParseable<int>.Parse(string s, IFormatProvider provider)
867 {
868 return Parse(s, provider);
869 }
870
871 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
872 static bool IParseable<int>.TryParse([NotNullWhen(true)] string s, IFormatProvider provider, out int result)
873 {
874 return TryParse(s, NumberStyles.Integer, provider, out result);
875 }
876
877 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
878 static int IShiftOperators<int, int>.operator <<(int value, int shiftAmount)
879 {
880 return value << shiftAmount;
881 }
882
883 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
884 static int IShiftOperators<int, int>.operator >>(int value, int shiftAmount)
885 {
886 return value >> shiftAmount;
887 }
888
889 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
891 {
892 return Parse(s, NumberStyles.Integer, provider);
893 }
894
895 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
896 static bool ISpanParseable<int>.TryParse(ReadOnlySpan<char> s, IFormatProvider provider, out int result)
897 {
898 return TryParse(s, NumberStyles.Integer, provider, out result);
899 }
900
901 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
902 static int ISubtractionOperators<int, int, int>.operator -(int left, int right)
903 {
904 return left - right;
905 }
906
907 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
908 static int IUnaryNegationOperators<int, int>.operator -(int value)
909 {
910 return -value;
911 }
912
913 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
914 static int IUnaryPlusOperators<int, int>.operator +(int value)
915 {
916 return value;
917 }
918}
static decimal ToDecimal(object? value)
Definition Convert.cs:2101
static long ToInt64(object? value)
Definition Convert.cs:1623
static float ToSingle(object? value)
Definition Convert.cs:1881
static short ToInt16(object? value)
Definition Convert.cs:1038
static byte ToByte(object? value)
Definition Convert.cs:900
static uint ToUInt32(object? value)
Definition Convert.cs:1470
static ulong ToUInt64(object? value)
Definition Convert.cs:1738
static char ToChar(object? value)
Definition Convert.cs:618
static ushort ToUInt16(object? value)
Definition Convert.cs:1177
static sbyte ToSByte(object? value)
Definition Convert.cs:745
static double ToDouble(object? value)
Definition Convert.cs:1991
static bool ToBoolean([NotNullWhen(true)] object? value)
Definition Convert.cs:508
static object DefaultToType(IConvertible value, Type targetType, IFormatProvider provider)
Definition Convert.cs:269
static void ValidateParseStyleInteger(NumberStyles style)
static NumberFormatInfo GetInstance(IFormatProvider? formatProvider)
static byte Clamp(byte value, byte min, byte max)
Definition Math.cs:435
static byte Min(byte val1, byte val2)
Definition Math.cs:912
static double Abs(double value)
static int DivRem(int a, int b, out int result)
Definition Math.cs:329
static int Sign(decimal value)
Definition Math.cs:1202
static byte Max(byte val1, byte val2)
Definition Math.cs:738
static int ParseInt32(ReadOnlySpan< char > value, NumberStyles styles, NumberFormatInfo info)
Definition Number.cs:3997
static ParsingStatus TryParseInt32IntegerStyle(ReadOnlySpan< char > value, NumberStyles styles, NumberFormatInfo info, out int result)
Definition Number.cs:4281
static string FormatInt32(int value, int hexMask, string format, IFormatProvider provider)
Definition Number.cs:1882
static string Int32ToDecStr(int value)
Definition Number.cs:2246
static ParsingStatus TryParseInt32(ReadOnlySpan< char > value, NumberStyles styles, NumberFormatInfo info, out int result)
Definition Number.cs:4251
static bool TryFormatInt32(int value, int hexMask, ReadOnlySpan< char > format, IFormatProvider provider, Span< char > destination, out int charsWritten)
Definition Number.cs:1929
static int TrailingZeroCount(int value)
static bool IsPow2(int value)
static int PopCount(uint value)
static int Log2(uint value)
static uint RotateRight(uint value, int offset)
static int LeadingZeroCount(uint value)
static uint RotateLeft(uint value, int offset)
static string InvalidCast_FromTo
Definition SR.cs:1392
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string Arg_MustBeInt32
Definition SR.cs:282
Definition SR.cs:7
static void ThrowNotSupportedException(ExceptionResource resource)
static void ThrowValueArgumentOutOfRange_NeedNonNegNumException()
static void ThrowArgumentNullException(string name)
static TResult AdditiveIdentity
static TSelf RotateRight(TSelf value, int rotateAmount)
static TSelf LeadingZeroCount(TSelf value)
static TSelf PopCount(TSelf value)
static TSelf TrailingZeroCount(TSelf value)
static TSelf RotateLeft(TSelf value, int rotateAmount)
static bool IsPow2(TSelf value)
static TSelf Log2(TSelf value)
short ToInt16(IFormatProvider? provider)
char ToChar(IFormatProvider? provider)
byte ToByte(IFormatProvider? provider)
decimal ToDecimal(IFormatProvider? provider)
object ToType(Type conversionType, IFormatProvider? provider)
uint ToUInt32(IFormatProvider? provider)
DateTime ToDateTime(IFormatProvider? provider)
int ToInt32(IFormatProvider? provider)
long ToInt64(IFormatProvider? provider)
ushort ToUInt16(IFormatProvider? provider)
double ToDouble(IFormatProvider? provider)
float ToSingle(IFormatProvider? provider)
sbyte ToSByte(IFormatProvider? provider)
ulong ToUInt64(IFormatProvider? provider)
bool ToBoolean(IFormatProvider? provider)
static TSelf MinValue
static TSelf MaxValue
static TSelf Max(TSelf x, TSelf y)
static bool TryParse([NotNullWhen(true)] string? s, NumberStyles style, IFormatProvider? provider, out TSelf result)
static TSelf Parse(string s, NumberStyles style, IFormatProvider? provider)
static TSelf Sign(TSelf value)
static TSelf Min(TSelf x, TSelf y)
static TSelf One
Definition INumber.cs:10
static TSelf Zero
Definition INumber.cs:12
static TSelf Abs(TSelf value)
static TSelf Clamp(TSelf value, TSelf min, TSelf max)
static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, out TSelf result)
static TSelf Parse(string s, IFormatProvider? provider)
static TSelf NegativeOne
static bool TryParse(ReadOnlySpan< char > s, IFormatProvider? provider, out TSelf result)
static TSelf Parse(ReadOnlySpan< char > s, IFormatProvider? provider)
TypeCode
Definition TypeCode.cs:4
static bool TryParse([NotNullWhen(true)] string? s, out int result)
Definition Int32.cs:163
override string ToString()
Definition Int32.cs:94
string ToString(string? format)
Definition Int32.cs:99
const int MinValue
Definition Int32.cs:17
static int int Remainder INumber< int >. DivRem(int left, int right)
Definition Int32.cs:691
static int Parse(string s)
Definition Int32.cs:119
string ToString(string? format, IFormatProvider? provider)
Definition Int32.cs:109
static int Parse(ReadOnlySpan< char > s, NumberStyles style=NumberStyles.Integer, IFormatProvider? provider=null)
Definition Int32.cs:157
static bool TryParse([NotNullWhen(true)] string? s, NumberStyles style, IFormatProvider? provider, out int result)
Definition Int32.cs:178
readonly int m_value
Definition Int32.cs:13
bool TryFormat(Span< char > destination, out int charsWritten, ReadOnlySpan< char > format=default(ReadOnlySpan< char >), IFormatProvider? provider=null)
Definition Int32.cs:114
int CompareTo(int value)
Definition Int32.cs:61
static bool TryParse(ReadOnlySpan< char > s, NumberStyles style, IFormatProvider? provider, out int result)
Definition Int32.cs:189
const int MaxValue
Definition Int32.cs:15
int CompareTo(object? value)
Definition Int32.cs:40
static int Quotient
Definition Int32.cs:691
static int Parse(string s, NumberStyles style, IFormatProvider? provider)
Definition Int32.cs:147
string ToString(IFormatProvider? provider)
Definition Int32.cs:104
static bool TryParse(ReadOnlySpan< char > s, out int result)
Definition Int32.cs:173
override bool Equals([NotNullWhen(true)] object? obj)
Definition Int32.cs:74
override int GetHashCode()
Definition Int32.cs:89
static int Parse(string s, NumberStyles style)
Definition Int32.cs:128
TypeCode GetTypeCode()
Definition Int32.cs:195
static int Create< TOther >(TOther value)
Definition Int32.cs:430
bool Equals(int obj)
Definition Int32.cs:84
static int Parse(string s, IFormatProvider? provider)
Definition Int32.cs:138
static IntPtr MaxValue
Definition IntPtr.cs:30
static IntPtr MinValue
Definition IntPtr.cs:39
static UIntPtr MaxValue
Definition UIntPtr.cs:31