Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
Convert.cs
Go to the documentation of this file.
6
7namespace System;
8
9public static class Convert
10{
11 internal static readonly Type[] ConvertTypes = new Type[19]
12 {
13 typeof(Empty),
14 typeof(object),
15 typeof(DBNull),
16 typeof(bool),
17 typeof(char),
18 typeof(sbyte),
19 typeof(byte),
20 typeof(short),
21 typeof(ushort),
22 typeof(int),
23 typeof(uint),
24 typeof(long),
25 typeof(ulong),
26 typeof(float),
27 typeof(double),
28 typeof(decimal),
29 typeof(DateTime),
30 typeof(object),
31 typeof(string)
32 };
33
34 private static readonly Type EnumType = typeof(Enum);
35
36 internal static readonly char[] base64Table = new char[65]
37 {
38 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
39 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
40 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd',
41 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
42 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x',
43 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7',
44 '8', '9', '+', '/', '='
45 };
46
47 public static readonly object DBNull = System.DBNull.Value;
48
49 private static ReadOnlySpan<sbyte> DecodingMap => new sbyte[256]
50 {
51 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
52 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
53 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
54 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
55 -1, -1, -1, 62, -1, -1, -1, 63, 52, 53,
56 54, 55, 56, 57, 58, 59, 60, 61, -1, -1,
57 -1, -1, -1, -1, -1, 0, 1, 2, 3, 4,
58 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
59 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
60 25, -1, -1, -1, -1, -1, -1, 26, 27, 28,
61 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
62 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
63 49, 50, 51, -1, -1, -1, -1, -1, -1, -1,
64 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
65 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
66 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
67 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
68 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
69 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
70 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
71 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
72 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
73 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
74 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
75 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
76 -1, -1, -1, -1, -1, -1
77 };
78
79 private static bool TryDecodeFromUtf16(ReadOnlySpan<char> utf16, Span<byte> bytes, out int consumed, out int written)
80 {
81 ref char reference = ref MemoryMarshal.GetReference(utf16);
82 ref byte reference2 = ref MemoryMarshal.GetReference(bytes);
83 int num = utf16.Length & -4;
84 int length = bytes.Length;
85 int num2 = 0;
86 int num3 = 0;
87 if (utf16.Length != 0)
88 {
89 ref sbyte reference3 = ref MemoryMarshal.GetReference(DecodingMap);
90 int num4 = ((length < (num >> 2) * 3) ? (length / 3 * 4) : (num - 4));
91 while (true)
92 {
93 if (num2 < num4)
94 {
95 int num5 = Decode(ref Unsafe.Add(ref reference, num2), ref reference3);
96 if (num5 >= 0)
97 {
98 WriteThreeLowOrderBytes(ref Unsafe.Add(ref reference2, num3), num5);
99 num3 += 3;
100 num2 += 4;
101 continue;
102 }
103 }
104 else if (num4 == num - 4 && num2 != num)
105 {
106 int num6 = Unsafe.Add(ref reference, num - 4);
107 int num7 = Unsafe.Add(ref reference, num - 3);
108 int num8 = Unsafe.Add(ref reference, num - 2);
109 int num9 = Unsafe.Add(ref reference, num - 1);
110 if (((num6 | num7 | num8 | num9) & 0xFFFFFF00u) == 0L)
111 {
112 num6 = Unsafe.Add(ref reference3, num6);
113 num7 = Unsafe.Add(ref reference3, num7);
114 num6 <<= 18;
115 num7 <<= 12;
116 num6 |= num7;
117 if (num9 != 61)
118 {
119 num8 = Unsafe.Add(ref reference3, num8);
120 num9 = Unsafe.Add(ref reference3, num9);
121 num8 <<= 6;
122 num6 |= num9;
123 num6 |= num8;
124 if (num6 >= 0 && num3 <= length - 3)
125 {
126 WriteThreeLowOrderBytes(ref Unsafe.Add(ref reference2, num3), num6);
127 num3 += 3;
128 goto IL_01e6;
129 }
130 }
131 else if (num8 != 61)
132 {
133 num8 = Unsafe.Add(ref reference3, num8);
134 num8 <<= 6;
135 num6 |= num8;
136 if (num6 >= 0 && num3 <= length - 2)
137 {
138 Unsafe.Add(ref reference2, num3) = (byte)(num6 >> 16);
139 Unsafe.Add(ref reference2, num3 + 1) = (byte)(num6 >> 8);
140 num3 += 2;
141 goto IL_01e6;
142 }
143 }
144 else if (num6 >= 0 && num3 <= length - 1)
145 {
146 Unsafe.Add(ref reference2, num3) = (byte)(num6 >> 16);
147 num3++;
148 goto IL_01e6;
149 }
150 }
151 }
152 goto IL_0200;
153 IL_0200:
154 consumed = num2;
155 written = num3;
156 return false;
157 IL_01e6:
158 num2 += 4;
159 if (num == utf16.Length)
160 {
161 break;
162 }
163 goto IL_0200;
164 }
165 }
166 consumed = num2;
167 written = num3;
168 return true;
169 }
170
171 [MethodImpl(MethodImplOptions.AggressiveInlining)]
172 private static int Decode(ref char encodedChars, ref sbyte decodingMap)
173 {
174 int num = encodedChars;
175 int num2 = Unsafe.Add(ref encodedChars, 1);
176 int num3 = Unsafe.Add(ref encodedChars, 2);
177 int num4 = Unsafe.Add(ref encodedChars, 3);
178 if (((num | num2 | num3 | num4) & 0xFFFFFF00u) != 0L)
179 {
180 return -1;
181 }
182 num = Unsafe.Add(ref decodingMap, num);
183 num2 = Unsafe.Add(ref decodingMap, num2);
184 num3 = Unsafe.Add(ref decodingMap, num3);
185 num4 = Unsafe.Add(ref decodingMap, num4);
186 num <<= 18;
187 num2 <<= 12;
188 num3 <<= 6;
189 num |= num4;
190 num2 |= num3;
191 return num | num2;
192 }
193
194 [MethodImpl(MethodImplOptions.AggressiveInlining)]
195 private static void WriteThreeLowOrderBytes(ref byte destination, int value)
196 {
197 destination = (byte)(value >> 16);
198 Unsafe.Add(ref destination, 1) = (byte)(value >> 8);
199 Unsafe.Add(ref destination, 2) = (byte)value;
200 }
201
202 public static TypeCode GetTypeCode(object? value)
203 {
204 if (value == null)
205 {
206 return TypeCode.Empty;
207 }
208 if (value is IConvertible convertible)
209 {
210 return convertible.GetTypeCode();
211 }
212 return TypeCode.Object;
213 }
214
215 public static bool IsDBNull([NotNullWhen(true)] object? value)
216 {
217 if (value == System.DBNull.Value)
218 {
219 return true;
220 }
221 if (!(value is IConvertible convertible))
222 {
223 return false;
224 }
225 return convertible.GetTypeCode() == TypeCode.DBNull;
226 }
227
228 [return: NotNullIfNotNull("value")]
229 public static object? ChangeType(object? value, TypeCode typeCode)
230 {
231 return ChangeType(value, typeCode, CultureInfo.CurrentCulture);
232 }
233
234 [return: NotNullIfNotNull("value")]
235 public static object? ChangeType(object? value, TypeCode typeCode, IFormatProvider? provider)
236 {
237 if (value == null && (typeCode == TypeCode.Empty || typeCode == TypeCode.String || typeCode == TypeCode.Object))
238 {
239 return null;
240 }
241 if (!(value is IConvertible convertible))
242 {
244 }
245 return typeCode switch
246 {
247 TypeCode.Boolean => convertible.ToBoolean(provider),
248 TypeCode.Char => convertible.ToChar(provider),
249 TypeCode.SByte => convertible.ToSByte(provider),
250 TypeCode.Byte => convertible.ToByte(provider),
251 TypeCode.Int16 => convertible.ToInt16(provider),
252 TypeCode.UInt16 => convertible.ToUInt16(provider),
253 TypeCode.Int32 => convertible.ToInt32(provider),
254 TypeCode.UInt32 => convertible.ToUInt32(provider),
255 TypeCode.Int64 => convertible.ToInt64(provider),
256 TypeCode.UInt64 => convertible.ToUInt64(provider),
257 TypeCode.Single => convertible.ToSingle(provider),
258 TypeCode.Double => convertible.ToDouble(provider),
259 TypeCode.Decimal => convertible.ToDecimal(provider),
260 TypeCode.DateTime => convertible.ToDateTime(provider),
261 TypeCode.String => convertible.ToString(provider),
262 TypeCode.Object => value,
263 TypeCode.DBNull => throw new InvalidCastException(SR.InvalidCast_DBNull),
264 TypeCode.Empty => throw new InvalidCastException(SR.InvalidCast_Empty),
266 };
267 }
268
269 internal static object DefaultToType(IConvertible value, Type targetType, IFormatProvider provider)
270 {
271 if (targetType == null)
272 {
273 throw new ArgumentNullException("targetType");
274 }
275 if ((object)value.GetType() == targetType)
276 {
277 return value;
278 }
279 if ((object)targetType == ConvertTypes[3])
280 {
281 return value.ToBoolean(provider);
282 }
283 if ((object)targetType == ConvertTypes[4])
284 {
285 return value.ToChar(provider);
286 }
287 if ((object)targetType == ConvertTypes[5])
288 {
289 return value.ToSByte(provider);
290 }
291 if ((object)targetType == ConvertTypes[6])
292 {
293 return value.ToByte(provider);
294 }
295 if ((object)targetType == ConvertTypes[7])
296 {
297 return value.ToInt16(provider);
298 }
299 if ((object)targetType == ConvertTypes[8])
300 {
301 return value.ToUInt16(provider);
302 }
303 if ((object)targetType == ConvertTypes[9])
304 {
305 return value.ToInt32(provider);
306 }
307 if ((object)targetType == ConvertTypes[10])
308 {
309 return value.ToUInt32(provider);
310 }
311 if ((object)targetType == ConvertTypes[11])
312 {
313 return value.ToInt64(provider);
314 }
315 if ((object)targetType == ConvertTypes[12])
316 {
317 return value.ToUInt64(provider);
318 }
319 if ((object)targetType == ConvertTypes[13])
320 {
321 return value.ToSingle(provider);
322 }
323 if ((object)targetType == ConvertTypes[14])
324 {
325 return value.ToDouble(provider);
326 }
327 if ((object)targetType == ConvertTypes[15])
328 {
329 return value.ToDecimal(provider);
330 }
331 if ((object)targetType == ConvertTypes[16])
332 {
333 return value.ToDateTime(provider);
334 }
335 if ((object)targetType == ConvertTypes[18])
336 {
337 return value.ToString(provider);
338 }
339 if ((object)targetType == ConvertTypes[1])
340 {
341 return value;
342 }
343 if ((object)targetType == EnumType)
344 {
345 return (Enum)value;
346 }
347 if ((object)targetType == ConvertTypes[2])
348 {
350 }
351 if ((object)targetType == ConvertTypes[0])
352 {
354 }
355 throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, value.GetType().FullName, targetType.FullName));
356 }
357
358 [return: NotNullIfNotNull("value")]
359 public static object? ChangeType(object? value, Type conversionType)
360 {
361 return ChangeType(value, conversionType, CultureInfo.CurrentCulture);
362 }
363
364 [return: NotNullIfNotNull("value")]
365 public static object? ChangeType(object? value, Type conversionType, IFormatProvider? provider)
366 {
367 if ((object)conversionType == null)
368 {
369 throw new ArgumentNullException("conversionType");
370 }
371 if (value == null)
372 {
373 if (conversionType.IsValueType)
374 {
376 }
377 return null;
378 }
379 if (!(value is IConvertible convertible))
380 {
381 if (value.GetType() == conversionType)
382 {
383 return value;
384 }
386 }
387 if ((object)conversionType == ConvertTypes[3])
388 {
389 return convertible.ToBoolean(provider);
390 }
391 if ((object)conversionType == ConvertTypes[4])
392 {
393 return convertible.ToChar(provider);
394 }
395 if ((object)conversionType == ConvertTypes[5])
396 {
397 return convertible.ToSByte(provider);
398 }
399 if ((object)conversionType == ConvertTypes[6])
400 {
401 return convertible.ToByte(provider);
402 }
403 if ((object)conversionType == ConvertTypes[7])
404 {
405 return convertible.ToInt16(provider);
406 }
407 if ((object)conversionType == ConvertTypes[8])
408 {
409 return convertible.ToUInt16(provider);
410 }
411 if ((object)conversionType == ConvertTypes[9])
412 {
413 return convertible.ToInt32(provider);
414 }
415 if ((object)conversionType == ConvertTypes[10])
416 {
417 return convertible.ToUInt32(provider);
418 }
419 if ((object)conversionType == ConvertTypes[11])
420 {
421 return convertible.ToInt64(provider);
422 }
423 if ((object)conversionType == ConvertTypes[12])
424 {
425 return convertible.ToUInt64(provider);
426 }
427 if ((object)conversionType == ConvertTypes[13])
428 {
429 return convertible.ToSingle(provider);
430 }
431 if ((object)conversionType == ConvertTypes[14])
432 {
433 return convertible.ToDouble(provider);
434 }
435 if ((object)conversionType == ConvertTypes[15])
436 {
437 return convertible.ToDecimal(provider);
438 }
439 if ((object)conversionType == ConvertTypes[16])
440 {
441 return convertible.ToDateTime(provider);
442 }
443 if ((object)conversionType == ConvertTypes[18])
444 {
445 return convertible.ToString(provider);
446 }
447 if ((object)conversionType == ConvertTypes[1])
448 {
449 return value;
450 }
451 return convertible.ToType(conversionType, provider);
452 }
453
454 [DoesNotReturn]
455 private static void ThrowCharOverflowException()
456 {
458 }
459
460 [DoesNotReturn]
461 private static void ThrowByteOverflowException()
462 {
464 }
465
466 [DoesNotReturn]
467 private static void ThrowSByteOverflowException()
468 {
470 }
471
472 [DoesNotReturn]
473 private static void ThrowInt16OverflowException()
474 {
476 }
477
478 [DoesNotReturn]
479 private static void ThrowUInt16OverflowException()
480 {
482 }
483
484 [DoesNotReturn]
485 private static void ThrowInt32OverflowException()
486 {
488 }
489
490 [DoesNotReturn]
491 private static void ThrowUInt32OverflowException()
492 {
494 }
495
496 [DoesNotReturn]
497 private static void ThrowInt64OverflowException()
498 {
500 }
501
502 [DoesNotReturn]
503 private static void ThrowUInt64OverflowException()
504 {
506 }
507
508 public static bool ToBoolean([NotNullWhen(true)] object? value)
509 {
510 if (value != null)
511 {
512 return ((IConvertible)value).ToBoolean(null);
513 }
514 return false;
515 }
516
517 public static bool ToBoolean([NotNullWhen(true)] object? value, IFormatProvider? provider)
518 {
519 if (value != null)
520 {
521 return ((IConvertible)value).ToBoolean(provider);
522 }
523 return false;
524 }
525
526 public static bool ToBoolean(bool value)
527 {
528 return value;
529 }
530
531 [CLSCompliant(false)]
532 public static bool ToBoolean(sbyte value)
533 {
534 return value != 0;
535 }
536
537 public static bool ToBoolean(char value)
538 {
539 return ((IConvertible)value).ToBoolean((IFormatProvider?)null);
540 }
541
542 public static bool ToBoolean(byte value)
543 {
544 return value != 0;
545 }
546
547 public static bool ToBoolean(short value)
548 {
549 return value != 0;
550 }
551
552 [CLSCompliant(false)]
553 public static bool ToBoolean(ushort value)
554 {
555 return value != 0;
556 }
557
558 public static bool ToBoolean(int value)
559 {
560 return value != 0;
561 }
562
563 [CLSCompliant(false)]
564 public static bool ToBoolean(uint value)
565 {
566 return value != 0;
567 }
568
569 public static bool ToBoolean(long value)
570 {
571 return value != 0;
572 }
573
574 [CLSCompliant(false)]
575 public static bool ToBoolean(ulong value)
576 {
577 return value != 0;
578 }
579
580 public static bool ToBoolean([NotNullWhen(true)] string? value)
581 {
582 if (value == null)
583 {
584 return false;
585 }
586 return bool.Parse(value);
587 }
588
589 public static bool ToBoolean([NotNullWhen(true)] string? value, IFormatProvider? provider)
590 {
591 if (value == null)
592 {
593 return false;
594 }
595 return bool.Parse(value);
596 }
597
598 public static bool ToBoolean(float value)
599 {
600 return value != 0f;
601 }
602
603 public static bool ToBoolean(double value)
604 {
605 return value != 0.0;
606 }
607
608 public static bool ToBoolean(decimal value)
609 {
610 return value != 0m;
611 }
612
613 public static bool ToBoolean(DateTime value)
614 {
615 return ((IConvertible)value).ToBoolean((IFormatProvider?)null);
616 }
617
618 public static char ToChar(object? value)
619 {
620 if (value != null)
621 {
622 return ((IConvertible)value).ToChar(null);
623 }
624 return '\0';
625 }
626
627 public static char ToChar(object? value, IFormatProvider? provider)
628 {
629 if (value != null)
630 {
631 return ((IConvertible)value).ToChar(provider);
632 }
633 return '\0';
634 }
635
636 public static char ToChar(bool value)
637 {
638 return ((IConvertible)value).ToChar((IFormatProvider?)null);
639 }
640
641 public static char ToChar(char value)
642 {
643 return value;
644 }
645
646 [CLSCompliant(false)]
647 public static char ToChar(sbyte value)
648 {
649 if (value < 0)
650 {
652 }
653 return (char)value;
654 }
655
656 public static char ToChar(byte value)
657 {
658 return (char)value;
659 }
660
661 public static char ToChar(short value)
662 {
663 if (value < 0)
664 {
666 }
667 return (char)value;
668 }
669
670 [CLSCompliant(false)]
671 public static char ToChar(ushort value)
672 {
673 return (char)value;
674 }
675
676 public static char ToChar(int value)
677 {
678 return ToChar((uint)value);
679 }
680
681 [CLSCompliant(false)]
682 public static char ToChar(uint value)
683 {
684 if (value > 65535)
685 {
687 }
688 return (char)value;
689 }
690
691 public static char ToChar(long value)
692 {
693 return ToChar((ulong)value);
694 }
695
696 [CLSCompliant(false)]
697 public static char ToChar(ulong value)
698 {
699 if (value > 65535)
700 {
702 }
703 return (char)value;
704 }
705
706 public static char ToChar(string value)
707 {
708 return ToChar(value, null);
709 }
710
711 public static char ToChar(string value, IFormatProvider? provider)
712 {
713 if (value == null)
714 {
715 throw new ArgumentNullException("value");
716 }
717 if (value.Length != 1)
718 {
720 }
721 return value[0];
722 }
723
724 public static char ToChar(float value)
725 {
726 return ((IConvertible)value).ToChar((IFormatProvider?)null);
727 }
728
729 public static char ToChar(double value)
730 {
731 return ((IConvertible)value).ToChar((IFormatProvider?)null);
732 }
733
734 public static char ToChar(decimal value)
735 {
736 return ((IConvertible)value).ToChar((IFormatProvider?)null);
737 }
738
739 public static char ToChar(DateTime value)
740 {
741 return ((IConvertible)value).ToChar((IFormatProvider?)null);
742 }
743
744 [CLSCompliant(false)]
745 public static sbyte ToSByte(object? value)
746 {
747 if (value != null)
748 {
749 return ((IConvertible)value).ToSByte(null);
750 }
751 return 0;
752 }
753
754 [CLSCompliant(false)]
755 public static sbyte ToSByte(object? value, IFormatProvider? provider)
756 {
757 if (value != null)
758 {
759 return ((IConvertible)value).ToSByte(provider);
760 }
761 return 0;
762 }
763
764 [CLSCompliant(false)]
765 public static sbyte ToSByte(bool value)
766 {
767 if (!value)
768 {
769 return 0;
770 }
771 return 1;
772 }
773
774 [CLSCompliant(false)]
775 public static sbyte ToSByte(sbyte value)
776 {
777 return value;
778 }
779
780 [CLSCompliant(false)]
781 public static sbyte ToSByte(char value)
782 {
783 if (value > '\u007f')
784 {
786 }
787 return (sbyte)value;
788 }
789
790 [CLSCompliant(false)]
791 public static sbyte ToSByte(byte value)
792 {
793 if (value > 127)
794 {
796 }
797 return (sbyte)value;
798 }
799
800 [CLSCompliant(false)]
801 public static sbyte ToSByte(short value)
802 {
803 if (value < -128 || value > 127)
804 {
806 }
807 return (sbyte)value;
808 }
809
810 [CLSCompliant(false)]
811 public static sbyte ToSByte(ushort value)
812 {
813 if (value > 127)
814 {
816 }
817 return (sbyte)value;
818 }
819
820 [CLSCompliant(false)]
821 public static sbyte ToSByte(int value)
822 {
823 if (value < -128 || value > 127)
824 {
826 }
827 return (sbyte)value;
828 }
829
830 [CLSCompliant(false)]
831 public static sbyte ToSByte(uint value)
832 {
833 if (value > 127)
834 {
836 }
837 return (sbyte)value;
838 }
839
840 [CLSCompliant(false)]
841 public static sbyte ToSByte(long value)
842 {
843 if (value < -128 || value > 127)
844 {
846 }
847 return (sbyte)value;
848 }
849
850 [CLSCompliant(false)]
851 public static sbyte ToSByte(ulong value)
852 {
853 if (value > 127)
854 {
856 }
857 return (sbyte)value;
858 }
859
860 [CLSCompliant(false)]
861 public static sbyte ToSByte(float value)
862 {
863 return ToSByte((double)value);
864 }
865
866 [CLSCompliant(false)]
867 public static sbyte ToSByte(double value)
868 {
869 return ToSByte(ToInt32(value));
870 }
871
872 [CLSCompliant(false)]
873 public static sbyte ToSByte(decimal value)
874 {
875 return decimal.ToSByte(decimal.Round(value, 0));
876 }
877
878 [CLSCompliant(false)]
879 public static sbyte ToSByte(string? value)
880 {
881 if (value == null)
882 {
883 return 0;
884 }
885 return sbyte.Parse(value);
886 }
887
888 [CLSCompliant(false)]
889 public static sbyte ToSByte(string value, IFormatProvider? provider)
890 {
891 return sbyte.Parse(value, provider);
892 }
893
894 [CLSCompliant(false)]
895 public static sbyte ToSByte(DateTime value)
896 {
897 return ((IConvertible)value).ToSByte((IFormatProvider?)null);
898 }
899
900 public static byte ToByte(object? value)
901 {
902 if (value != null)
903 {
904 return ((IConvertible)value).ToByte(null);
905 }
906 return 0;
907 }
908
909 public static byte ToByte(object? value, IFormatProvider? provider)
910 {
911 if (value != null)
912 {
913 return ((IConvertible)value).ToByte(provider);
914 }
915 return 0;
916 }
917
918 public static byte ToByte(bool value)
919 {
920 if (!value)
921 {
922 return 0;
923 }
924 return 1;
925 }
926
927 public static byte ToByte(byte value)
928 {
929 return value;
930 }
931
932 public static byte ToByte(char value)
933 {
934 if (value > 'ÿ')
935 {
937 }
938 return (byte)value;
939 }
940
941 [CLSCompliant(false)]
942 public static byte ToByte(sbyte value)
943 {
944 if (value < 0)
945 {
947 }
948 return (byte)value;
949 }
950
951 public static byte ToByte(short value)
952 {
953 if ((uint)value > 255u)
954 {
956 }
957 return (byte)value;
958 }
959
960 [CLSCompliant(false)]
961 public static byte ToByte(ushort value)
962 {
963 if (value > 255)
964 {
966 }
967 return (byte)value;
968 }
969
970 public static byte ToByte(int value)
971 {
972 return ToByte((uint)value);
973 }
974
975 [CLSCompliant(false)]
976 public static byte ToByte(uint value)
977 {
978 if (value > 255)
979 {
981 }
982 return (byte)value;
983 }
984
985 public static byte ToByte(long value)
986 {
987 return ToByte((ulong)value);
988 }
989
990 [CLSCompliant(false)]
991 public static byte ToByte(ulong value)
992 {
993 if (value > 255)
994 {
996 }
997 return (byte)value;
998 }
999
1000 public static byte ToByte(float value)
1001 {
1002 return ToByte((double)value);
1003 }
1004
1005 public static byte ToByte(double value)
1006 {
1007 return ToByte(ToInt32(value));
1008 }
1009
1010 public static byte ToByte(decimal value)
1011 {
1012 return decimal.ToByte(decimal.Round(value, 0));
1013 }
1014
1015 public static byte ToByte(string? value)
1016 {
1017 if (value == null)
1018 {
1019 return 0;
1020 }
1021 return byte.Parse(value);
1022 }
1023
1024 public static byte ToByte(string? value, IFormatProvider? provider)
1025 {
1026 if (value == null)
1027 {
1028 return 0;
1029 }
1030 return byte.Parse(value, provider);
1031 }
1032
1033 public static byte ToByte(DateTime value)
1034 {
1035 return ((IConvertible)value).ToByte((IFormatProvider?)null);
1036 }
1037
1038 public static short ToInt16(object? value)
1039 {
1040 if (value != null)
1041 {
1042 return ((IConvertible)value).ToInt16(null);
1043 }
1044 return 0;
1045 }
1046
1047 public static short ToInt16(object? value, IFormatProvider? provider)
1048 {
1049 if (value != null)
1050 {
1051 return ((IConvertible)value).ToInt16(provider);
1052 }
1053 return 0;
1054 }
1055
1056 public static short ToInt16(bool value)
1057 {
1058 if (!value)
1059 {
1060 return 0;
1061 }
1062 return 1;
1063 }
1064
1065 public static short ToInt16(char value)
1066 {
1067 if (value > 'ç¿¿')
1068 {
1070 }
1071 return (short)value;
1072 }
1073
1074 [CLSCompliant(false)]
1075 public static short ToInt16(sbyte value)
1076 {
1077 return value;
1078 }
1079
1080 public static short ToInt16(byte value)
1081 {
1082 return value;
1083 }
1084
1085 [CLSCompliant(false)]
1086 public static short ToInt16(ushort value)
1087 {
1088 if (value > 32767)
1089 {
1091 }
1092 return (short)value;
1093 }
1094
1095 public static short ToInt16(int value)
1096 {
1097 if (value < -32768 || value > 32767)
1098 {
1100 }
1101 return (short)value;
1102 }
1103
1104 [CLSCompliant(false)]
1105 public static short ToInt16(uint value)
1106 {
1107 if (value > 32767)
1108 {
1110 }
1111 return (short)value;
1112 }
1113
1114 public static short ToInt16(short value)
1115 {
1116 return value;
1117 }
1118
1119 public static short ToInt16(long value)
1120 {
1121 if (value < -32768 || value > 32767)
1122 {
1124 }
1125 return (short)value;
1126 }
1127
1128 [CLSCompliant(false)]
1129 public static short ToInt16(ulong value)
1130 {
1131 if (value > 32767)
1132 {
1134 }
1135 return (short)value;
1136 }
1137
1138 public static short ToInt16(float value)
1139 {
1140 return ToInt16((double)value);
1141 }
1142
1143 public static short ToInt16(double value)
1144 {
1145 return ToInt16(ToInt32(value));
1146 }
1147
1148 public static short ToInt16(decimal value)
1149 {
1150 return decimal.ToInt16(decimal.Round(value, 0));
1151 }
1152
1153 public static short ToInt16(string? value)
1154 {
1155 if (value == null)
1156 {
1157 return 0;
1158 }
1159 return short.Parse(value);
1160 }
1161
1162 public static short ToInt16(string? value, IFormatProvider? provider)
1163 {
1164 if (value == null)
1165 {
1166 return 0;
1167 }
1168 return short.Parse(value, provider);
1169 }
1170
1171 public static short ToInt16(DateTime value)
1172 {
1173 return ((IConvertible)value).ToInt16((IFormatProvider?)null);
1174 }
1175
1176 [CLSCompliant(false)]
1177 public static ushort ToUInt16(object? value)
1178 {
1179 if (value != null)
1180 {
1181 return ((IConvertible)value).ToUInt16(null);
1182 }
1183 return 0;
1184 }
1185
1186 [CLSCompliant(false)]
1187 public static ushort ToUInt16(object? value, IFormatProvider? provider)
1188 {
1189 if (value != null)
1190 {
1191 return ((IConvertible)value).ToUInt16(provider);
1192 }
1193 return 0;
1194 }
1195
1196 [CLSCompliant(false)]
1197 public static ushort ToUInt16(bool value)
1198 {
1199 if (!value)
1200 {
1201 return 0;
1202 }
1203 return 1;
1204 }
1205
1206 [CLSCompliant(false)]
1207 public static ushort ToUInt16(char value)
1208 {
1209 return value;
1210 }
1211
1212 [CLSCompliant(false)]
1213 public static ushort ToUInt16(sbyte value)
1214 {
1215 if (value < 0)
1216 {
1218 }
1219 return (ushort)value;
1220 }
1221
1222 [CLSCompliant(false)]
1223 public static ushort ToUInt16(byte value)
1224 {
1225 return value;
1226 }
1227
1228 [CLSCompliant(false)]
1229 public static ushort ToUInt16(short value)
1230 {
1231 if (value < 0)
1232 {
1234 }
1235 return (ushort)value;
1236 }
1237
1238 [CLSCompliant(false)]
1239 public static ushort ToUInt16(int value)
1240 {
1241 return ToUInt16((uint)value);
1242 }
1243
1244 [CLSCompliant(false)]
1245 public static ushort ToUInt16(ushort value)
1246 {
1247 return value;
1248 }
1249
1250 [CLSCompliant(false)]
1251 public static ushort ToUInt16(uint value)
1252 {
1253 if (value > 65535)
1254 {
1256 }
1257 return (ushort)value;
1258 }
1259
1260 [CLSCompliant(false)]
1261 public static ushort ToUInt16(long value)
1262 {
1263 return ToUInt16((ulong)value);
1264 }
1265
1266 [CLSCompliant(false)]
1267 public static ushort ToUInt16(ulong value)
1268 {
1269 if (value > 65535)
1270 {
1272 }
1273 return (ushort)value;
1274 }
1275
1276 [CLSCompliant(false)]
1277 public static ushort ToUInt16(float value)
1278 {
1279 return ToUInt16((double)value);
1280 }
1281
1282 [CLSCompliant(false)]
1283 public static ushort ToUInt16(double value)
1284 {
1285 return ToUInt16(ToInt32(value));
1286 }
1287
1288 [CLSCompliant(false)]
1289 public static ushort ToUInt16(decimal value)
1290 {
1291 return decimal.ToUInt16(decimal.Round(value, 0));
1292 }
1293
1294 [CLSCompliant(false)]
1295 public static ushort ToUInt16(string? value)
1296 {
1297 if (value == null)
1298 {
1299 return 0;
1300 }
1301 return ushort.Parse(value);
1302 }
1303
1304 [CLSCompliant(false)]
1305 public static ushort ToUInt16(string? value, IFormatProvider? provider)
1306 {
1307 if (value == null)
1308 {
1309 return 0;
1310 }
1311 return ushort.Parse(value, provider);
1312 }
1313
1314 [CLSCompliant(false)]
1315 public static ushort ToUInt16(DateTime value)
1316 {
1317 return ((IConvertible)value).ToUInt16((IFormatProvider?)null);
1318 }
1319
1320 public static int ToInt32(object? value)
1321 {
1322 if (value != null)
1323 {
1324 return ((IConvertible)value).ToInt32(null);
1325 }
1326 return 0;
1327 }
1328
1329 public static int ToInt32(object? value, IFormatProvider? provider)
1330 {
1331 if (value != null)
1332 {
1333 return ((IConvertible)value).ToInt32(provider);
1334 }
1335 return 0;
1336 }
1337
1338 public static int ToInt32(bool value)
1339 {
1340 if (!value)
1341 {
1342 return 0;
1343 }
1344 return 1;
1345 }
1346
1347 public static int ToInt32(char value)
1348 {
1349 return value;
1350 }
1351
1352 [CLSCompliant(false)]
1353 public static int ToInt32(sbyte value)
1354 {
1355 return value;
1356 }
1357
1358 public static int ToInt32(byte value)
1359 {
1360 return value;
1361 }
1362
1363 public static int ToInt32(short value)
1364 {
1365 return value;
1366 }
1367
1368 [CLSCompliant(false)]
1369 public static int ToInt32(ushort value)
1370 {
1371 return value;
1372 }
1373
1374 [CLSCompliant(false)]
1375 public static int ToInt32(uint value)
1376 {
1377 if ((int)value < 0)
1378 {
1380 }
1381 return (int)value;
1382 }
1383
1384 public static int ToInt32(int value)
1385 {
1386 return value;
1387 }
1388
1389 public static int ToInt32(long value)
1390 {
1391 if (value < int.MinValue || value > int.MaxValue)
1392 {
1394 }
1395 return (int)value;
1396 }
1397
1398 [CLSCompliant(false)]
1399 public static int ToInt32(ulong value)
1400 {
1401 if (value > int.MaxValue)
1402 {
1404 }
1405 return (int)value;
1406 }
1407
1408 public static int ToInt32(float value)
1409 {
1410 return ToInt32((double)value);
1411 }
1412
1413 public static int ToInt32(double value)
1414 {
1415 if (value >= 0.0)
1416 {
1417 if (value < 2147483647.5)
1418 {
1419 int num = (int)value;
1420 double num2 = value - (double)num;
1421 if (num2 > 0.5 || (num2 == 0.5 && ((uint)num & (true ? 1u : 0u)) != 0))
1422 {
1423 num++;
1424 }
1425 return num;
1426 }
1427 }
1428 else if (value >= -2147483648.5)
1429 {
1430 int num3 = (int)value;
1431 double num4 = value - (double)num3;
1432 if (num4 < -0.5 || (num4 == -0.5 && ((uint)num3 & (true ? 1u : 0u)) != 0))
1433 {
1434 num3--;
1435 }
1436 return num3;
1437 }
1439 }
1440
1441 public static int ToInt32(decimal value)
1442 {
1443 return decimal.ToInt32(decimal.Round(value, 0));
1444 }
1445
1446 public static int ToInt32(string? value)
1447 {
1448 if (value == null)
1449 {
1450 return 0;
1451 }
1452 return int.Parse(value);
1453 }
1454
1455 public static int ToInt32(string? value, IFormatProvider? provider)
1456 {
1457 if (value == null)
1458 {
1459 return 0;
1460 }
1461 return int.Parse(value, provider);
1462 }
1463
1464 public static int ToInt32(DateTime value)
1465 {
1466 return ((IConvertible)value).ToInt32((IFormatProvider?)null);
1467 }
1468
1469 [CLSCompliant(false)]
1470 public static uint ToUInt32(object? value)
1471 {
1472 if (value != null)
1473 {
1474 return ((IConvertible)value).ToUInt32(null);
1475 }
1476 return 0u;
1477 }
1478
1479 [CLSCompliant(false)]
1480 public static uint ToUInt32(object? value, IFormatProvider? provider)
1481 {
1482 if (value != null)
1483 {
1484 return ((IConvertible)value).ToUInt32(provider);
1485 }
1486 return 0u;
1487 }
1488
1489 [CLSCompliant(false)]
1490 public static uint ToUInt32(bool value)
1491 {
1492 if (!value)
1493 {
1494 return 0u;
1495 }
1496 return 1u;
1497 }
1498
1499 [CLSCompliant(false)]
1500 public static uint ToUInt32(char value)
1501 {
1502 return value;
1503 }
1504
1505 [CLSCompliant(false)]
1506 public static uint ToUInt32(sbyte value)
1507 {
1508 if (value < 0)
1509 {
1511 }
1512 return (uint)value;
1513 }
1514
1515 [CLSCompliant(false)]
1516 public static uint ToUInt32(byte value)
1517 {
1518 return value;
1519 }
1520
1521 [CLSCompliant(false)]
1522 public static uint ToUInt32(short value)
1523 {
1524 if (value < 0)
1525 {
1527 }
1528 return (uint)value;
1529 }
1530
1531 [CLSCompliant(false)]
1532 public static uint ToUInt32(ushort value)
1533 {
1534 return value;
1535 }
1536
1537 [CLSCompliant(false)]
1538 public static uint ToUInt32(int value)
1539 {
1540 if (value < 0)
1541 {
1543 }
1544 return (uint)value;
1545 }
1546
1547 [CLSCompliant(false)]
1548 public static uint ToUInt32(uint value)
1549 {
1550 return value;
1551 }
1552
1553 [CLSCompliant(false)]
1554 public static uint ToUInt32(long value)
1555 {
1556 return ToUInt32((ulong)value);
1557 }
1558
1559 [CLSCompliant(false)]
1560 public static uint ToUInt32(ulong value)
1561 {
1562 if (value > uint.MaxValue)
1563 {
1565 }
1566 return (uint)value;
1567 }
1568
1569 [CLSCompliant(false)]
1570 public static uint ToUInt32(float value)
1571 {
1572 return ToUInt32((double)value);
1573 }
1574
1575 [CLSCompliant(false)]
1576 public static uint ToUInt32(double value)
1577 {
1578 if (value >= -0.5 && value < 4294967295.5)
1579 {
1580 uint num = (uint)value;
1581 double num2 = value - (double)num;
1582 if (num2 > 0.5 || (num2 == 0.5 && (num & (true ? 1u : 0u)) != 0))
1583 {
1584 num++;
1585 }
1586 return num;
1587 }
1589 }
1590
1591 [CLSCompliant(false)]
1592 public static uint ToUInt32(decimal value)
1593 {
1594 return decimal.ToUInt32(decimal.Round(value, 0));
1595 }
1596
1597 [CLSCompliant(false)]
1598 public static uint ToUInt32(string? value)
1599 {
1600 if (value == null)
1601 {
1602 return 0u;
1603 }
1604 return uint.Parse(value);
1605 }
1606
1607 [CLSCompliant(false)]
1608 public static uint ToUInt32(string? value, IFormatProvider? provider)
1609 {
1610 if (value == null)
1611 {
1612 return 0u;
1613 }
1614 return uint.Parse(value, provider);
1615 }
1616
1617 [CLSCompliant(false)]
1618 public static uint ToUInt32(DateTime value)
1619 {
1620 return ((IConvertible)value).ToUInt32((IFormatProvider?)null);
1621 }
1622
1623 public static long ToInt64(object? value)
1624 {
1625 if (value != null)
1626 {
1627 return ((IConvertible)value).ToInt64(null);
1628 }
1629 return 0L;
1630 }
1631
1632 public static long ToInt64(object? value, IFormatProvider? provider)
1633 {
1634 if (value != null)
1635 {
1636 return ((IConvertible)value).ToInt64(provider);
1637 }
1638 return 0L;
1639 }
1640
1641 public static long ToInt64(bool value)
1642 {
1643 return value ? 1 : 0;
1644 }
1645
1646 public static long ToInt64(char value)
1647 {
1648 return value;
1649 }
1650
1651 [CLSCompliant(false)]
1652 public static long ToInt64(sbyte value)
1653 {
1654 return value;
1655 }
1656
1657 public static long ToInt64(byte value)
1658 {
1659 return value;
1660 }
1661
1662 public static long ToInt64(short value)
1663 {
1664 return value;
1665 }
1666
1667 [CLSCompliant(false)]
1668 public static long ToInt64(ushort value)
1669 {
1670 return value;
1671 }
1672
1673 public static long ToInt64(int value)
1674 {
1675 return value;
1676 }
1677
1678 [CLSCompliant(false)]
1679 public static long ToInt64(uint value)
1680 {
1681 return value;
1682 }
1683
1684 [CLSCompliant(false)]
1685 public static long ToInt64(ulong value)
1686 {
1687 if ((long)value < 0L)
1688 {
1690 }
1691 return (long)value;
1692 }
1693
1694 public static long ToInt64(long value)
1695 {
1696 return value;
1697 }
1698
1699 public static long ToInt64(float value)
1700 {
1701 return ToInt64((double)value);
1702 }
1703
1704 public static long ToInt64(double value)
1705 {
1706 return checked((long)Math.Round(value));
1707 }
1708
1709 public static long ToInt64(decimal value)
1710 {
1711 return decimal.ToInt64(decimal.Round(value, 0));
1712 }
1713
1714 public static long ToInt64(string? value)
1715 {
1716 if (value == null)
1717 {
1718 return 0L;
1719 }
1720 return long.Parse(value);
1721 }
1722
1723 public static long ToInt64(string? value, IFormatProvider? provider)
1724 {
1725 if (value == null)
1726 {
1727 return 0L;
1728 }
1729 return long.Parse(value, provider);
1730 }
1731
1732 public static long ToInt64(DateTime value)
1733 {
1734 return ((IConvertible)value).ToInt64((IFormatProvider?)null);
1735 }
1736
1737 [CLSCompliant(false)]
1738 public static ulong ToUInt64(object? value)
1739 {
1740 if (value != null)
1741 {
1742 return ((IConvertible)value).ToUInt64(null);
1743 }
1744 return 0uL;
1745 }
1746
1747 [CLSCompliant(false)]
1748 public static ulong ToUInt64(object? value, IFormatProvider? provider)
1749 {
1750 if (value != null)
1751 {
1752 return ((IConvertible)value).ToUInt64(provider);
1753 }
1754 return 0uL;
1755 }
1756
1757 [CLSCompliant(false)]
1758 public static ulong ToUInt64(bool value)
1759 {
1760 if (!value)
1761 {
1762 return 0uL;
1763 }
1764 return 1uL;
1765 }
1766
1767 [CLSCompliant(false)]
1768 public static ulong ToUInt64(char value)
1769 {
1770 return value;
1771 }
1772
1773 [CLSCompliant(false)]
1774 public static ulong ToUInt64(sbyte value)
1775 {
1776 if (value < 0)
1777 {
1779 }
1780 return (ulong)value;
1781 }
1782
1783 [CLSCompliant(false)]
1784 public static ulong ToUInt64(byte value)
1785 {
1786 return value;
1787 }
1788
1789 [CLSCompliant(false)]
1790 public static ulong ToUInt64(short value)
1791 {
1792 if (value < 0)
1793 {
1795 }
1796 return (ulong)value;
1797 }
1798
1799 [CLSCompliant(false)]
1800 public static ulong ToUInt64(ushort value)
1801 {
1802 return value;
1803 }
1804
1805 [CLSCompliant(false)]
1806 public static ulong ToUInt64(int value)
1807 {
1808 if (value < 0)
1809 {
1811 }
1812 return (ulong)value;
1813 }
1814
1815 [CLSCompliant(false)]
1816 public static ulong ToUInt64(uint value)
1817 {
1818 return value;
1819 }
1820
1821 [CLSCompliant(false)]
1822 public static ulong ToUInt64(long value)
1823 {
1824 if (value < 0)
1825 {
1827 }
1828 return (ulong)value;
1829 }
1830
1831 [CLSCompliant(false)]
1832 public static ulong ToUInt64(ulong value)
1833 {
1834 return value;
1835 }
1836
1837 [CLSCompliant(false)]
1838 public static ulong ToUInt64(float value)
1839 {
1840 return ToUInt64((double)value);
1841 }
1842
1843 [CLSCompliant(false)]
1844 public static ulong ToUInt64(double value)
1845 {
1846 return checked((ulong)Math.Round(value));
1847 }
1848
1849 [CLSCompliant(false)]
1850 public static ulong ToUInt64(decimal value)
1851 {
1852 return decimal.ToUInt64(decimal.Round(value, 0));
1853 }
1854
1855 [CLSCompliant(false)]
1856 public static ulong ToUInt64(string? value)
1857 {
1858 if (value == null)
1859 {
1860 return 0uL;
1861 }
1862 return ulong.Parse(value);
1863 }
1864
1865 [CLSCompliant(false)]
1866 public static ulong ToUInt64(string? value, IFormatProvider? provider)
1867 {
1868 if (value == null)
1869 {
1870 return 0uL;
1871 }
1872 return ulong.Parse(value, provider);
1873 }
1874
1875 [CLSCompliant(false)]
1876 public static ulong ToUInt64(DateTime value)
1877 {
1878 return ((IConvertible)value).ToUInt64((IFormatProvider?)null);
1879 }
1880
1881 public static float ToSingle(object? value)
1882 {
1883 if (value != null)
1884 {
1885 return ((IConvertible)value).ToSingle(null);
1886 }
1887 return 0f;
1888 }
1889
1890 public static float ToSingle(object? value, IFormatProvider? provider)
1891 {
1892 if (value != null)
1893 {
1894 return ((IConvertible)value).ToSingle(provider);
1895 }
1896 return 0f;
1897 }
1898
1899 [CLSCompliant(false)]
1900 public static float ToSingle(sbyte value)
1901 {
1902 return value;
1903 }
1904
1905 public static float ToSingle(byte value)
1906 {
1907 return (int)value;
1908 }
1909
1910 public static float ToSingle(char value)
1911 {
1912 return ((IConvertible)value).ToSingle((IFormatProvider?)null);
1913 }
1914
1915 public static float ToSingle(short value)
1916 {
1917 return value;
1918 }
1919
1920 [CLSCompliant(false)]
1921 public static float ToSingle(ushort value)
1922 {
1923 return (int)value;
1924 }
1925
1926 public static float ToSingle(int value)
1927 {
1928 return value;
1929 }
1930
1931 [CLSCompliant(false)]
1932 public static float ToSingle(uint value)
1933 {
1934 return value;
1935 }
1936
1937 public static float ToSingle(long value)
1938 {
1939 return value;
1940 }
1941
1942 [CLSCompliant(false)]
1943 public static float ToSingle(ulong value)
1944 {
1945 return value;
1946 }
1947
1948 public static float ToSingle(float value)
1949 {
1950 return value;
1951 }
1952
1953 public static float ToSingle(double value)
1954 {
1955 return (float)value;
1956 }
1957
1958 public static float ToSingle(decimal value)
1959 {
1960 return (float)value;
1961 }
1962
1963 public static float ToSingle(string? value)
1964 {
1965 if (value == null)
1966 {
1967 return 0f;
1968 }
1969 return float.Parse(value);
1970 }
1971
1972 public static float ToSingle(string? value, IFormatProvider? provider)
1973 {
1974 if (value == null)
1975 {
1976 return 0f;
1977 }
1978 return float.Parse(value, provider);
1979 }
1980
1981 public static float ToSingle(bool value)
1982 {
1983 return value ? 1 : 0;
1984 }
1985
1986 public static float ToSingle(DateTime value)
1987 {
1988 return ((IConvertible)value).ToSingle((IFormatProvider?)null);
1989 }
1990
1991 public static double ToDouble(object? value)
1992 {
1993 if (value != null)
1994 {
1995 return ((IConvertible)value).ToDouble(null);
1996 }
1997 return 0.0;
1998 }
1999
2000 public static double ToDouble(object? value, IFormatProvider? provider)
2001 {
2002 if (value != null)
2003 {
2004 return ((IConvertible)value).ToDouble(provider);
2005 }
2006 return 0.0;
2007 }
2008
2009 [CLSCompliant(false)]
2010 public static double ToDouble(sbyte value)
2011 {
2012 return value;
2013 }
2014
2015 public static double ToDouble(byte value)
2016 {
2017 return (int)value;
2018 }
2019
2020 public static double ToDouble(short value)
2021 {
2022 return value;
2023 }
2024
2025 public static double ToDouble(char value)
2026 {
2027 return ((IConvertible)value).ToDouble((IFormatProvider?)null);
2028 }
2029
2030 [CLSCompliant(false)]
2031 public static double ToDouble(ushort value)
2032 {
2033 return (int)value;
2034 }
2035
2036 public static double ToDouble(int value)
2037 {
2038 return value;
2039 }
2040
2041 [CLSCompliant(false)]
2042 public static double ToDouble(uint value)
2043 {
2044 return value;
2045 }
2046
2047 public static double ToDouble(long value)
2048 {
2049 return value;
2050 }
2051
2052 [CLSCompliant(false)]
2053 public static double ToDouble(ulong value)
2054 {
2055 return value;
2056 }
2057
2058 public static double ToDouble(float value)
2059 {
2060 return value;
2061 }
2062
2063 public static double ToDouble(double value)
2064 {
2065 return value;
2066 }
2067
2068 public static double ToDouble(decimal value)
2069 {
2070 return (double)value;
2071 }
2072
2073 public static double ToDouble(string? value)
2074 {
2075 if (value == null)
2076 {
2077 return 0.0;
2078 }
2079 return double.Parse(value);
2080 }
2081
2082 public static double ToDouble(string? value, IFormatProvider? provider)
2083 {
2084 if (value == null)
2085 {
2086 return 0.0;
2087 }
2088 return double.Parse(value, provider);
2089 }
2090
2091 public static double ToDouble(bool value)
2092 {
2093 return value ? 1 : 0;
2094 }
2095
2096 public static double ToDouble(DateTime value)
2097 {
2098 return ((IConvertible)value).ToDouble((IFormatProvider?)null);
2099 }
2100
2101 public static decimal ToDecimal(object? value)
2102 {
2103 if (value != null)
2104 {
2105 return ((IConvertible)value).ToDecimal(null);
2106 }
2107 return 0m;
2108 }
2109
2110 public static decimal ToDecimal(object? value, IFormatProvider? provider)
2111 {
2112 if (value != null)
2113 {
2114 return ((IConvertible)value).ToDecimal(provider);
2115 }
2116 return 0m;
2117 }
2118
2119 [CLSCompliant(false)]
2120 public static decimal ToDecimal(sbyte value)
2121 {
2122 return value;
2123 }
2124
2125 public static decimal ToDecimal(byte value)
2126 {
2127 return value;
2128 }
2129
2130 public static decimal ToDecimal(char value)
2131 {
2132 return ((IConvertible)value).ToDecimal((IFormatProvider?)null);
2133 }
2134
2135 public static decimal ToDecimal(short value)
2136 {
2137 return value;
2138 }
2139
2140 [CLSCompliant(false)]
2141 public static decimal ToDecimal(ushort value)
2142 {
2143 return value;
2144 }
2145
2146 public static decimal ToDecimal(int value)
2147 {
2148 return value;
2149 }
2150
2151 [CLSCompliant(false)]
2152 public static decimal ToDecimal(uint value)
2153 {
2154 return value;
2155 }
2156
2157 public static decimal ToDecimal(long value)
2158 {
2159 return value;
2160 }
2161
2162 [CLSCompliant(false)]
2163 public static decimal ToDecimal(ulong value)
2164 {
2165 return value;
2166 }
2167
2168 public static decimal ToDecimal(float value)
2169 {
2170 return (decimal)value;
2171 }
2172
2173 public static decimal ToDecimal(double value)
2174 {
2175 return (decimal)value;
2176 }
2177
2178 public static decimal ToDecimal(string? value)
2179 {
2180 if (value == null)
2181 {
2182 return 0m;
2183 }
2184 return decimal.Parse(value);
2185 }
2186
2187 public static decimal ToDecimal(string? value, IFormatProvider? provider)
2188 {
2189 if (value == null)
2190 {
2191 return 0m;
2192 }
2193 return decimal.Parse(value, provider);
2194 }
2195
2196 public static decimal ToDecimal(decimal value)
2197 {
2198 return value;
2199 }
2200
2201 public static decimal ToDecimal(bool value)
2202 {
2203 return value ? 1 : 0;
2204 }
2205
2206 public static decimal ToDecimal(DateTime value)
2207 {
2208 return ((IConvertible)value).ToDecimal((IFormatProvider?)null);
2209 }
2210
2212 {
2213 return value;
2214 }
2215
2216 public static DateTime ToDateTime(object? value)
2217 {
2218 if (value != null)
2219 {
2220 return ((IConvertible)value).ToDateTime(null);
2221 }
2222 return DateTime.MinValue;
2223 }
2224
2225 public static DateTime ToDateTime(object? value, IFormatProvider? provider)
2226 {
2227 if (value != null)
2228 {
2229 return ((IConvertible)value).ToDateTime(provider);
2230 }
2231 return DateTime.MinValue;
2232 }
2233
2234 public static DateTime ToDateTime(string? value)
2235 {
2236 if (value == null)
2237 {
2238 return new DateTime(0L);
2239 }
2240 return DateTime.Parse(value);
2241 }
2242
2243 public static DateTime ToDateTime(string? value, IFormatProvider? provider)
2244 {
2245 if (value == null)
2246 {
2247 return new DateTime(0L);
2248 }
2249 return DateTime.Parse(value, provider);
2250 }
2251
2252 [CLSCompliant(false)]
2253 public static DateTime ToDateTime(sbyte value)
2254 {
2255 return ((IConvertible)value).ToDateTime((IFormatProvider?)null);
2256 }
2257
2258 public static DateTime ToDateTime(byte value)
2259 {
2260 return ((IConvertible)value).ToDateTime((IFormatProvider?)null);
2261 }
2262
2263 public static DateTime ToDateTime(short value)
2264 {
2265 return ((IConvertible)value).ToDateTime((IFormatProvider?)null);
2266 }
2267
2268 [CLSCompliant(false)]
2269 public static DateTime ToDateTime(ushort value)
2270 {
2271 return ((IConvertible)value).ToDateTime((IFormatProvider?)null);
2272 }
2273
2274 public static DateTime ToDateTime(int value)
2275 {
2276 return ((IConvertible)value).ToDateTime((IFormatProvider?)null);
2277 }
2278
2279 [CLSCompliant(false)]
2280 public static DateTime ToDateTime(uint value)
2281 {
2282 return ((IConvertible)value).ToDateTime((IFormatProvider?)null);
2283 }
2284
2285 public static DateTime ToDateTime(long value)
2286 {
2287 return ((IConvertible)value).ToDateTime((IFormatProvider?)null);
2288 }
2289
2290 [CLSCompliant(false)]
2291 public static DateTime ToDateTime(ulong value)
2292 {
2293 return ((IConvertible)value).ToDateTime((IFormatProvider?)null);
2294 }
2295
2296 public static DateTime ToDateTime(bool value)
2297 {
2298 return ((IConvertible)value).ToDateTime((IFormatProvider?)null);
2299 }
2300
2301 public static DateTime ToDateTime(char value)
2302 {
2303 return ((IConvertible)value).ToDateTime((IFormatProvider?)null);
2304 }
2305
2306 public static DateTime ToDateTime(float value)
2307 {
2308 return ((IConvertible)value).ToDateTime((IFormatProvider?)null);
2309 }
2310
2311 public static DateTime ToDateTime(double value)
2312 {
2313 return ((IConvertible)value).ToDateTime((IFormatProvider?)null);
2314 }
2315
2316 public static DateTime ToDateTime(decimal value)
2317 {
2318 return ((IConvertible)value).ToDateTime((IFormatProvider?)null);
2319 }
2320
2321 public static string? ToString(object? value)
2322 {
2323 return ToString(value, null);
2324 }
2325
2326 public static string? ToString(object? value, IFormatProvider? provider)
2327 {
2328 if (value is IConvertible convertible)
2329 {
2330 return convertible.ToString(provider);
2331 }
2332 if (value is IFormattable formattable)
2333 {
2334 return formattable.ToString(null, provider);
2335 }
2336 if (value != null)
2337 {
2338 return value.ToString();
2339 }
2340 return string.Empty;
2341 }
2342
2343 public static string ToString(bool value)
2344 {
2345 return value.ToString();
2346 }
2347
2348 public static string ToString(bool value, IFormatProvider? provider)
2349 {
2350 return value.ToString();
2351 }
2352
2353 public static string ToString(char value)
2354 {
2355 return char.ToString(value);
2356 }
2357
2358 public static string ToString(char value, IFormatProvider? provider)
2359 {
2360 return value.ToString();
2361 }
2362
2363 [CLSCompliant(false)]
2364 public static string ToString(sbyte value)
2365 {
2366 return value.ToString();
2367 }
2368
2369 [CLSCompliant(false)]
2370 public static string ToString(sbyte value, IFormatProvider? provider)
2371 {
2372 return value.ToString(provider);
2373 }
2374
2375 public static string ToString(byte value)
2376 {
2377 return value.ToString();
2378 }
2379
2380 public static string ToString(byte value, IFormatProvider? provider)
2381 {
2382 return value.ToString(provider);
2383 }
2384
2385 public static string ToString(short value)
2386 {
2387 return value.ToString();
2388 }
2389
2390 public static string ToString(short value, IFormatProvider? provider)
2391 {
2392 return value.ToString(provider);
2393 }
2394
2395 [CLSCompliant(false)]
2396 public static string ToString(ushort value)
2397 {
2398 return value.ToString();
2399 }
2400
2401 [CLSCompliant(false)]
2402 public static string ToString(ushort value, IFormatProvider? provider)
2403 {
2404 return value.ToString(provider);
2405 }
2406
2407 public static string ToString(int value)
2408 {
2409 return value.ToString();
2410 }
2411
2412 public static string ToString(int value, IFormatProvider? provider)
2413 {
2414 return value.ToString(provider);
2415 }
2416
2417 [CLSCompliant(false)]
2418 public static string ToString(uint value)
2419 {
2420 return value.ToString();
2421 }
2422
2423 [CLSCompliant(false)]
2424 public static string ToString(uint value, IFormatProvider? provider)
2425 {
2426 return value.ToString(provider);
2427 }
2428
2429 public static string ToString(long value)
2430 {
2431 return value.ToString();
2432 }
2433
2434 public static string ToString(long value, IFormatProvider? provider)
2435 {
2436 return value.ToString(provider);
2437 }
2438
2439 [CLSCompliant(false)]
2440 public static string ToString(ulong value)
2441 {
2442 return value.ToString();
2443 }
2444
2445 [CLSCompliant(false)]
2446 public static string ToString(ulong value, IFormatProvider? provider)
2447 {
2448 return value.ToString(provider);
2449 }
2450
2451 public static string ToString(float value)
2452 {
2453 return value.ToString();
2454 }
2455
2456 public static string ToString(float value, IFormatProvider? provider)
2457 {
2458 return value.ToString(provider);
2459 }
2460
2461 public static string ToString(double value)
2462 {
2463 return value.ToString();
2464 }
2465
2466 public static string ToString(double value, IFormatProvider? provider)
2467 {
2468 return value.ToString(provider);
2469 }
2470
2471 public static string ToString(decimal value)
2472 {
2473 return value.ToString();
2474 }
2475
2476 public static string ToString(decimal value, IFormatProvider? provider)
2477 {
2478 return value.ToString(provider);
2479 }
2480
2481 public static string ToString(DateTime value)
2482 {
2483 return value.ToString();
2484 }
2485
2486 public static string ToString(DateTime value, IFormatProvider? provider)
2487 {
2488 return value.ToString(provider);
2489 }
2490
2491 [return: NotNullIfNotNull("value")]
2492 public static string? ToString(string? value)
2493 {
2494 return value;
2495 }
2496
2497 [return: NotNullIfNotNull("value")]
2498 public static string? ToString(string? value, IFormatProvider? provider)
2499 {
2500 return value;
2501 }
2502
2503 public static byte ToByte(string? value, int fromBase)
2504 {
2505 if (fromBase != 2 && fromBase != 8 && fromBase != 10 && fromBase != 16)
2506 {
2508 }
2509 if (value == null)
2510 {
2511 return 0;
2512 }
2513 int num = ParseNumbers.StringToInt(value.AsSpan(), fromBase, 4608);
2514 if ((uint)num > 255u)
2515 {
2517 }
2518 return (byte)num;
2519 }
2520
2521 [CLSCompliant(false)]
2522 public static sbyte ToSByte(string? value, int fromBase)
2523 {
2524 if (fromBase != 2 && fromBase != 8 && fromBase != 10 && fromBase != 16)
2525 {
2527 }
2528 if (value == null)
2529 {
2530 return 0;
2531 }
2532 int num = ParseNumbers.StringToInt(value.AsSpan(), fromBase, 5120);
2533 if (fromBase != 10 && num <= 255)
2534 {
2535 return (sbyte)num;
2536 }
2537 if (num < -128 || num > 127)
2538 {
2540 }
2541 return (sbyte)num;
2542 }
2543
2544 public static short ToInt16(string? value, int fromBase)
2545 {
2546 if (fromBase != 2 && fromBase != 8 && fromBase != 10 && fromBase != 16)
2547 {
2549 }
2550 if (value == null)
2551 {
2552 return 0;
2553 }
2554 int num = ParseNumbers.StringToInt(value.AsSpan(), fromBase, 6144);
2555 if (fromBase != 10 && num <= 65535)
2556 {
2557 return (short)num;
2558 }
2559 if (num < -32768 || num > 32767)
2560 {
2562 }
2563 return (short)num;
2564 }
2565
2566 [CLSCompliant(false)]
2567 public static ushort ToUInt16(string? value, int fromBase)
2568 {
2569 if (fromBase != 2 && fromBase != 8 && fromBase != 10 && fromBase != 16)
2570 {
2572 }
2573 if (value == null)
2574 {
2575 return 0;
2576 }
2577 int num = ParseNumbers.StringToInt(value.AsSpan(), fromBase, 4608);
2578 if ((uint)num > 65535u)
2579 {
2581 }
2582 return (ushort)num;
2583 }
2584
2585 public static int ToInt32(string? value, int fromBase)
2586 {
2587 if (fromBase != 2 && fromBase != 8 && fromBase != 10 && fromBase != 16)
2588 {
2590 }
2591 if (value == null)
2592 {
2593 return 0;
2594 }
2595 return ParseNumbers.StringToInt(value.AsSpan(), fromBase, 4096);
2596 }
2597
2598 [CLSCompliant(false)]
2599 public static uint ToUInt32(string? value, int fromBase)
2600 {
2601 if (fromBase != 2 && fromBase != 8 && fromBase != 10 && fromBase != 16)
2602 {
2604 }
2605 if (value == null)
2606 {
2607 return 0u;
2608 }
2609 return (uint)ParseNumbers.StringToInt(value.AsSpan(), fromBase, 4608);
2610 }
2611
2612 public static long ToInt64(string? value, int fromBase)
2613 {
2614 if (fromBase != 2 && fromBase != 8 && fromBase != 10 && fromBase != 16)
2615 {
2617 }
2618 if (value == null)
2619 {
2620 return 0L;
2621 }
2622 return ParseNumbers.StringToLong(value.AsSpan(), fromBase, 4096);
2623 }
2624
2625 [CLSCompliant(false)]
2626 public static ulong ToUInt64(string? value, int fromBase)
2627 {
2628 if (fromBase != 2 && fromBase != 8 && fromBase != 10 && fromBase != 16)
2629 {
2631 }
2632 if (value == null)
2633 {
2634 return 0uL;
2635 }
2636 return (ulong)ParseNumbers.StringToLong(value.AsSpan(), fromBase, 4608);
2637 }
2638
2639 public static string ToString(byte value, int toBase)
2640 {
2641 if (toBase != 2 && toBase != 8 && toBase != 10 && toBase != 16)
2642 {
2644 }
2645 return ParseNumbers.IntToString(value, toBase, -1, ' ', 64);
2646 }
2647
2648 public static string ToString(short value, int toBase)
2649 {
2650 if (toBase != 2 && toBase != 8 && toBase != 10 && toBase != 16)
2651 {
2653 }
2654 return ParseNumbers.IntToString(value, toBase, -1, ' ', 128);
2655 }
2656
2657 public static string ToString(int value, int toBase)
2658 {
2659 if (toBase != 2 && toBase != 8 && toBase != 10 && toBase != 16)
2660 {
2662 }
2663 return ParseNumbers.IntToString(value, toBase, -1, ' ', 0);
2664 }
2665
2666 public static string ToString(long value, int toBase)
2667 {
2668 if (toBase != 2 && toBase != 8 && toBase != 10 && toBase != 16)
2669 {
2671 }
2672 return ParseNumbers.LongToString(value, toBase, -1, ' ', 0);
2673 }
2674
2675 public static string ToBase64String(byte[] inArray)
2676 {
2677 if (inArray == null)
2678 {
2679 throw new ArgumentNullException("inArray");
2680 }
2681 return ToBase64String(new ReadOnlySpan<byte>(inArray));
2682 }
2683
2684 public static string ToBase64String(byte[] inArray, Base64FormattingOptions options)
2685 {
2686 if (inArray == null)
2687 {
2688 throw new ArgumentNullException("inArray");
2689 }
2690 return ToBase64String(new ReadOnlySpan<byte>(inArray), options);
2691 }
2692
2693 public static string ToBase64String(byte[] inArray, int offset, int length)
2694 {
2695 return ToBase64String(inArray, offset, length, Base64FormattingOptions.None);
2696 }
2697
2698 public static string ToBase64String(byte[] inArray, int offset, int length, Base64FormattingOptions options)
2699 {
2700 if (inArray == null)
2701 {
2702 throw new ArgumentNullException("inArray");
2703 }
2704 if (length < 0)
2705 {
2707 }
2708 if (offset < 0)
2709 {
2711 }
2712 if (offset > inArray.Length - length)
2713 {
2715 }
2716 return ToBase64String(new ReadOnlySpan<byte>(inArray, offset, length), options);
2717 }
2718
2720 {
2721 if (options < Base64FormattingOptions.None || options > Base64FormattingOptions.InsertLineBreaks)
2722 {
2723 throw new ArgumentException(SR.Format(SR.Arg_EnumIllegalVal, (int)options), "options");
2724 }
2725 if (bytes.Length == 0)
2726 {
2727 return string.Empty;
2728 }
2729 bool insertLineBreaks = options == Base64FormattingOptions.InsertLineBreaks;
2730 string text = string.FastAllocateString(ToBase64_CalculateAndValidateOutputLength(bytes.Length, insertLineBreaks));
2731 fixed (byte* inData = &MemoryMarshal.GetReference(bytes))
2732 {
2733 fixed (char* outChars = text)
2734 {
2735 int num = ConvertToBase64Array(outChars, inData, 0, bytes.Length, insertLineBreaks);
2736 }
2737 }
2738 return text;
2739 }
2740
2741 public static int ToBase64CharArray(byte[] inArray, int offsetIn, int length, char[] outArray, int offsetOut)
2742 {
2743 return ToBase64CharArray(inArray, offsetIn, length, outArray, offsetOut, Base64FormattingOptions.None);
2744 }
2745
2746 public unsafe static int ToBase64CharArray(byte[] inArray, int offsetIn, int length, char[] outArray, int offsetOut, Base64FormattingOptions options)
2747 {
2748 if (inArray == null)
2749 {
2750 throw new ArgumentNullException("inArray");
2751 }
2752 if (outArray == null)
2753 {
2754 throw new ArgumentNullException("outArray");
2755 }
2756 if (length < 0)
2757 {
2759 }
2760 if (offsetIn < 0)
2761 {
2763 }
2764 if (offsetOut < 0)
2765 {
2767 }
2768 if (options < Base64FormattingOptions.None || options > Base64FormattingOptions.InsertLineBreaks)
2769 {
2770 throw new ArgumentException(SR.Format(SR.Arg_EnumIllegalVal, (int)options), "options");
2771 }
2772 int num = inArray.Length;
2773 if (offsetIn > num - length)
2774 {
2776 }
2777 if (num == 0)
2778 {
2779 return 0;
2780 }
2781 bool insertLineBreaks = options == Base64FormattingOptions.InsertLineBreaks;
2782 int num2 = outArray.Length;
2783 int num3 = ToBase64_CalculateAndValidateOutputLength(length, insertLineBreaks);
2784 if (offsetOut > num2 - num3)
2785 {
2787 }
2788 int result;
2789 fixed (char* outChars = &outArray[offsetOut])
2790 {
2791 fixed (byte* inData = &inArray[0])
2792 {
2793 result = ConvertToBase64Array(outChars, inData, offsetIn, length, insertLineBreaks);
2794 }
2795 }
2796 return result;
2797 }
2798
2800 {
2801 if (options < Base64FormattingOptions.None || options > Base64FormattingOptions.InsertLineBreaks)
2802 {
2803 throw new ArgumentException(SR.Format(SR.Arg_EnumIllegalVal, (int)options), "options");
2804 }
2805 if (bytes.Length == 0)
2806 {
2807 charsWritten = 0;
2808 return true;
2809 }
2810 bool insertLineBreaks = options == Base64FormattingOptions.InsertLineBreaks;
2811 int num = ToBase64_CalculateAndValidateOutputLength(bytes.Length, insertLineBreaks);
2812 if (num > chars.Length)
2813 {
2814 charsWritten = 0;
2815 return false;
2816 }
2817 fixed (char* outChars = &MemoryMarshal.GetReference(chars))
2818 {
2819 fixed (byte* inData = &MemoryMarshal.GetReference(bytes))
2820 {
2821 charsWritten = ConvertToBase64Array(outChars, inData, 0, bytes.Length, insertLineBreaks);
2822 return true;
2823 }
2824 }
2825 }
2826
2827 private unsafe static int ConvertToBase64Array(char* outChars, byte* inData, int offset, int length, bool insertLineBreaks)
2828 {
2829 int num = length % 3;
2830 int num2 = offset + (length - num);
2831 int num3 = 0;
2832 int num4 = 0;
2833 fixed (char* ptr = &base64Table[0])
2834 {
2835 int i;
2836 for (i = offset; i < num2; i += 3)
2837 {
2838 if (insertLineBreaks)
2839 {
2840 if (num4 == 76)
2841 {
2842 outChars[num3++] = '\r';
2843 outChars[num3++] = '\n';
2844 num4 = 0;
2845 }
2846 num4 += 4;
2847 }
2848 outChars[num3] = ptr[(inData[i] & 0xFC) >> 2];
2849 outChars[num3 + 1] = ptr[((inData[i] & 3) << 4) | ((inData[i + 1] & 0xF0) >> 4)];
2850 outChars[num3 + 2] = ptr[((inData[i + 1] & 0xF) << 2) | ((inData[i + 2] & 0xC0) >> 6)];
2851 outChars[num3 + 3] = ptr[inData[i + 2] & 0x3F];
2852 num3 += 4;
2853 }
2854 i = num2;
2855 if (insertLineBreaks && num != 0 && num4 == 76)
2856 {
2857 outChars[num3++] = '\r';
2858 outChars[num3++] = '\n';
2859 }
2860 switch (num)
2861 {
2862 case 2:
2863 outChars[num3] = ptr[(inData[i] & 0xFC) >> 2];
2864 outChars[num3 + 1] = ptr[((inData[i] & 3) << 4) | ((inData[i + 1] & 0xF0) >> 4)];
2865 outChars[num3 + 2] = ptr[(inData[i + 1] & 0xF) << 2];
2866 outChars[num3 + 3] = ptr[64];
2867 num3 += 4;
2868 break;
2869 case 1:
2870 outChars[num3] = ptr[(inData[i] & 0xFC) >> 2];
2871 outChars[num3 + 1] = ptr[(inData[i] & 3) << 4];
2872 outChars[num3 + 2] = ptr[64];
2873 outChars[num3 + 3] = ptr[64];
2874 num3 += 4;
2875 break;
2876 }
2877 }
2878 return num3;
2879 }
2880
2881 private static int ToBase64_CalculateAndValidateOutputLength(int inputLength, bool insertLineBreaks)
2882 {
2883 long num = ((long)inputLength + 2L) / 3 * 4;
2884 if (num == 0L)
2885 {
2886 return 0;
2887 }
2888 if (insertLineBreaks)
2889 {
2890 var (num2, num3) = Math.DivRem(num, 76L);
2891 if (num3 == 0L)
2892 {
2893 num2--;
2894 }
2895 num += num2 * 2;
2896 }
2897 if (num > int.MaxValue)
2898 {
2899 throw new OutOfMemoryException();
2900 }
2901 return (int)num;
2902 }
2903
2904 public unsafe static byte[] FromBase64String(string s)
2905 {
2906 if (s == null)
2907 {
2909 }
2910 fixed (char* inputPtr = s)
2911 {
2912 return FromBase64CharPtr(inputPtr, s.Length);
2913 }
2914 }
2915
2916 public static bool TryFromBase64String(string s, Span<byte> bytes, out int bytesWritten)
2917 {
2918 if (s == null)
2919 {
2921 }
2922 return TryFromBase64Chars(s.AsSpan(), bytes, out bytesWritten);
2923 }
2924
2925 public static bool TryFromBase64Chars(ReadOnlySpan<char> chars, Span<byte> bytes, out int bytesWritten)
2926 {
2927 Span<char> span = stackalloc char[4];
2928 bytesWritten = 0;
2929 while (chars.Length != 0)
2930 {
2931 int consumed;
2932 int written;
2933 bool flag = TryDecodeFromUtf16(chars, bytes, out consumed, out written);
2934 bytesWritten += written;
2935 if (flag)
2936 {
2937 return true;
2938 }
2939 chars = chars.Slice(consumed);
2940 bytes = bytes.Slice(written);
2941 if (chars[0].IsSpace())
2942 {
2943 int i;
2944 for (i = 1; i != chars.Length && chars[i].IsSpace(); i++)
2945 {
2946 }
2947 chars = chars.Slice(i);
2948 if (written % 3 != 0 && chars.Length != 0)
2949 {
2950 bytesWritten = 0;
2951 return false;
2952 }
2953 continue;
2954 }
2955 CopyToTempBufferWithoutWhiteSpace(chars, span, out var consumed2, out var charsWritten);
2956 if (((uint)charsWritten & 3u) != 0)
2957 {
2958 bytesWritten = 0;
2959 return false;
2960 }
2961 span = span.Slice(0, charsWritten);
2962 if (!TryDecodeFromUtf16(span, bytes, out var _, out var written2))
2963 {
2964 bytesWritten = 0;
2965 return false;
2966 }
2967 bytesWritten += written2;
2968 chars = chars.Slice(consumed2);
2969 bytes = bytes.Slice(written2);
2970 if (written2 % 3 == 0)
2971 {
2972 continue;
2973 }
2974 for (int j = 0; j < chars.Length; j++)
2975 {
2976 if (!chars[j].IsSpace())
2977 {
2978 bytesWritten = 0;
2979 return false;
2980 }
2981 }
2982 return true;
2983 }
2984 return true;
2985 }
2986
2987 private static void CopyToTempBufferWithoutWhiteSpace(ReadOnlySpan<char> chars, Span<char> tempBuffer, out int consumed, out int charsWritten)
2988 {
2989 charsWritten = 0;
2990 for (int i = 0; i < chars.Length; i++)
2991 {
2992 char c = chars[i];
2993 if (!c.IsSpace())
2994 {
2995 tempBuffer[charsWritten++] = c;
2996 if (charsWritten == tempBuffer.Length)
2997 {
2998 consumed = i + 1;
2999 return;
3000 }
3001 }
3002 }
3003 consumed = chars.Length;
3004 }
3005
3006 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3007 private static bool IsSpace(this char c)
3008 {
3009 if (c != ' ' && c != '\t' && c != '\r')
3010 {
3011 return c == '\n';
3012 }
3013 return true;
3014 }
3015
3016 public unsafe static byte[] FromBase64CharArray(char[] inArray, int offset, int length)
3017 {
3018 if (inArray == null)
3019 {
3020 throw new ArgumentNullException("inArray");
3021 }
3022 if (length < 0)
3023 {
3025 }
3026 if (offset < 0)
3027 {
3029 }
3030 if (offset > inArray.Length - length)
3031 {
3033 }
3034 if (inArray.Length == 0)
3035 {
3036 return Array.Empty<byte>();
3037 }
3038 fixed (char* ptr = &inArray[0])
3039 {
3040 return FromBase64CharPtr(ptr + offset, length);
3041 }
3042 }
3043
3044 private unsafe static byte[] FromBase64CharPtr(char* inputPtr, int inputLength)
3045 {
3046 while (inputLength > 0)
3047 {
3048 int num = inputPtr[inputLength - 1];
3049 if (num != 32 && num != 10 && num != 13 && num != 9)
3050 {
3051 break;
3052 }
3053 inputLength--;
3054 }
3055 int num2 = FromBase64_ComputeResultLength(inputPtr, inputLength);
3056 byte[] array = new byte[num2];
3057 if (!TryFromBase64Chars(new ReadOnlySpan<char>(inputPtr, inputLength), array, out var _))
3058 {
3060 }
3061 return array;
3062 }
3063
3064 private unsafe static int FromBase64_ComputeResultLength(char* inputPtr, int inputLength)
3065 {
3066 char* ptr = inputPtr + inputLength;
3067 int num = inputLength;
3068 int num2 = 0;
3069 while (inputPtr < ptr)
3070 {
3071 uint num3 = *inputPtr;
3072 inputPtr++;
3073 switch (num3)
3074 {
3075 case 0u:
3076 case 1u:
3077 case 2u:
3078 case 3u:
3079 case 4u:
3080 case 5u:
3081 case 6u:
3082 case 7u:
3083 case 8u:
3084 case 9u:
3085 case 10u:
3086 case 11u:
3087 case 12u:
3088 case 13u:
3089 case 14u:
3090 case 15u:
3091 case 16u:
3092 case 17u:
3093 case 18u:
3094 case 19u:
3095 case 20u:
3096 case 21u:
3097 case 22u:
3098 case 23u:
3099 case 24u:
3100 case 25u:
3101 case 26u:
3102 case 27u:
3103 case 28u:
3104 case 29u:
3105 case 30u:
3106 case 31u:
3107 case 32u:
3108 num--;
3109 break;
3110 case 61u:
3111 num--;
3112 num2++;
3113 break;
3114 }
3115 }
3116 switch (num2)
3117 {
3118 case 1:
3119 num2 = 2;
3120 break;
3121 case 2:
3122 num2 = 1;
3123 break;
3124 default:
3126 case 0:
3127 break;
3128 }
3129 return num / 4 * 3 + num2;
3130 }
3131
3132 public static byte[] FromHexString(string s)
3133 {
3134 if (s == null)
3135 {
3137 }
3138 return FromHexString(s.AsSpan());
3139 }
3140
3142 {
3143 if (chars.Length == 0)
3144 {
3145 return Array.Empty<byte>();
3146 }
3147 if ((uint)chars.Length % 2u != 0)
3148 {
3150 }
3151 byte[] array = GC.AllocateUninitializedArray<byte>(chars.Length >> 1);
3153 {
3155 }
3156 return array;
3157 }
3158
3159 public static string ToHexString(byte[] inArray)
3160 {
3161 if (inArray == null)
3162 {
3163 throw new ArgumentNullException("inArray");
3164 }
3165 return ToHexString(new ReadOnlySpan<byte>(inArray));
3166 }
3167
3168 public static string ToHexString(byte[] inArray, int offset, int length)
3169 {
3170 if (inArray == null)
3171 {
3172 throw new ArgumentNullException("inArray");
3173 }
3174 if (length < 0)
3175 {
3177 }
3178 if (offset < 0)
3179 {
3181 }
3182 if (offset > inArray.Length - length)
3183 {
3185 }
3186 return ToHexString(new ReadOnlySpan<byte>(inArray, offset, length));
3187 }
3188
3190 {
3191 if (bytes.Length == 0)
3192 {
3193 return string.Empty;
3194 }
3195 if (bytes.Length > 1073741823)
3196 {
3198 }
3199 return HexConverter.ToString(bytes);
3200 }
3201}
static ushort ToUInt16(char value)
Definition Convert.cs:1207
static float ToSingle(decimal value)
Definition Convert.cs:1958
static DateTime ToDateTime(long value)
Definition Convert.cs:2285
static bool ToBoolean(float value)
Definition Convert.cs:598
static double ToDouble(string? value)
Definition Convert.cs:2073
static string ToString(long value, int toBase)
Definition Convert.cs:2666
static decimal ToDecimal(float value)
Definition Convert.cs:2168
static sbyte ToSByte(string value, IFormatProvider? provider)
Definition Convert.cs:889
static ulong ToUInt64(string? value, IFormatProvider? provider)
Definition Convert.cs:1866
static DateTime ToDateTime(string? value, IFormatProvider? provider)
Definition Convert.cs:2243
static float ToSingle(string? value, IFormatProvider? provider)
Definition Convert.cs:1972
static float ToSingle(bool value)
Definition Convert.cs:1981
static sbyte ToSByte(float value)
Definition Convert.cs:861
static sbyte ToSByte(double value)
Definition Convert.cs:867
static byte ToByte(decimal value)
Definition Convert.cs:1010
static ? string ToString(object? value)
Definition Convert.cs:2321
static int ToInt32(string? value, IFormatProvider? provider)
Definition Convert.cs:1455
static decimal ToDecimal(object? value)
Definition Convert.cs:2101
static int ToInt32(string? value)
Definition Convert.cs:1446
static float ToSingle(ulong value)
Definition Convert.cs:1943
static short ToInt16(ushort value)
Definition Convert.cs:1086
static byte[] FromHexString(string s)
Definition Convert.cs:3132
static void ThrowInt32OverflowException()
Definition Convert.cs:485
static long ToInt64(object? value)
Definition Convert.cs:1623
static string ToString(int value, int toBase)
Definition Convert.cs:2657
static byte ToByte(float value)
Definition Convert.cs:1000
static ushort ToUInt16(float value)
Definition Convert.cs:1277
static int ToInt32(DateTime value)
Definition Convert.cs:1464
static string ToString(short value, int toBase)
Definition Convert.cs:2648
static decimal ToDecimal(bool value)
Definition Convert.cs:2201
static ushort ToUInt16(bool value)
Definition Convert.cs:1197
static string ToString(DateTime value)
Definition Convert.cs:2481
static byte ToByte(bool value)
Definition Convert.cs:918
static double ToDouble(float value)
Definition Convert.cs:2058
static char ToChar(sbyte value)
Definition Convert.cs:647
static uint ToUInt32(long value)
Definition Convert.cs:1554
static string ToString(DateTime value, IFormatProvider? provider)
Definition Convert.cs:2486
static ? object ChangeType(object? value, Type conversionType)
Definition Convert.cs:359
static ulong ToUInt64(ushort value)
Definition Convert.cs:1800
static DateTime ToDateTime(ulong value)
Definition Convert.cs:2291
static double ToDouble(DateTime value)
Definition Convert.cs:2096
static ulong ToUInt64(DateTime value)
Definition Convert.cs:1876
static long ToInt64(short value)
Definition Convert.cs:1662
static uint ToUInt32(string? value, IFormatProvider? provider)
Definition Convert.cs:1608
static string ToBase64String(byte[] inArray, Base64FormattingOptions options)
Definition Convert.cs:2684
static sbyte ToSByte(ushort value)
Definition Convert.cs:811
static sbyte ToSByte(string? value, int fromBase)
Definition Convert.cs:2522
static uint ToUInt32(char value)
Definition Convert.cs:1500
static bool ToBoolean(DateTime value)
Definition Convert.cs:613
static uint ToUInt32(ulong value)
Definition Convert.cs:1560
static byte ToByte(object? value, IFormatProvider? provider)
Definition Convert.cs:909
static long ToInt64(string? value)
Definition Convert.cs:1714
static ulong ToUInt64(long value)
Definition Convert.cs:1822
static ulong ToUInt64(string? value, int fromBase)
Definition Convert.cs:2626
static sbyte ToSByte(char value)
Definition Convert.cs:781
static byte ToByte(DateTime value)
Definition Convert.cs:1033
static sbyte ToSByte(uint value)
Definition Convert.cs:831
static bool IsDBNull([NotNullWhen(true)] object? value)
Definition Convert.cs:215
static uint ToUInt32(string? value)
Definition Convert.cs:1598
static string ToHexString(byte[] inArray, int offset, int length)
Definition Convert.cs:3168
static sbyte ToSByte(sbyte value)
Definition Convert.cs:775
static double ToDouble(decimal value)
Definition Convert.cs:2068
static short ToInt16(char value)
Definition Convert.cs:1065
static sbyte ToSByte(bool value)
Definition Convert.cs:765
static ushort ToUInt16(ushort value)
Definition Convert.cs:1245
static bool ToBoolean([NotNullWhen(true)] string? value)
Definition Convert.cs:580
static void CopyToTempBufferWithoutWhiteSpace(ReadOnlySpan< char > chars, Span< char > tempBuffer, out int consumed, out int charsWritten)
Definition Convert.cs:2987
static unsafe int FromBase64_ComputeResultLength(char *inputPtr, int inputLength)
Definition Convert.cs:3064
static ulong ToUInt64(decimal value)
Definition Convert.cs:1850
static uint ToUInt32(sbyte value)
Definition Convert.cs:1506
static decimal ToDecimal(sbyte value)
Definition Convert.cs:2120
static byte ToByte(int value)
Definition Convert.cs:970
static float ToSingle(DateTime value)
Definition Convert.cs:1986
static string ToString(int value)
Definition Convert.cs:2407
static long ToInt64(double value)
Definition Convert.cs:1704
static float ToSingle(uint value)
Definition Convert.cs:1932
static string ToString(char value, IFormatProvider? provider)
Definition Convert.cs:2358
static decimal ToDecimal(int value)
Definition Convert.cs:2146
static uint ToUInt32(decimal value)
Definition Convert.cs:1592
static ? string ToString(string? value)
Definition Convert.cs:2492
static double ToDouble(ulong value)
Definition Convert.cs:2053
static string ToString(decimal value)
Definition Convert.cs:2471
static ushort ToUInt16(byte value)
Definition Convert.cs:1223
static string ToString(ushort value, IFormatProvider? provider)
Definition Convert.cs:2402
static byte ToByte(short value)
Definition Convert.cs:951
static byte ToByte(long value)
Definition Convert.cs:985
static bool ToBoolean(sbyte value)
Definition Convert.cs:532
static uint ToUInt32(object? value, IFormatProvider? provider)
Definition Convert.cs:1480
static double ToDouble(short value)
Definition Convert.cs:2020
static double ToDouble(string? value, IFormatProvider? provider)
Definition Convert.cs:2082
static long ToInt64(float value)
Definition Convert.cs:1699
static decimal ToDecimal(ushort value)
Definition Convert.cs:2141
static string ToString(float value)
Definition Convert.cs:2451
static sbyte ToSByte(DateTime value)
Definition Convert.cs:895
static string ToBase64String(byte[] inArray, int offset, int length, Base64FormattingOptions options)
Definition Convert.cs:2698
static string ToHexString(ReadOnlySpan< byte > bytes)
Definition Convert.cs:3189
static string ToBase64String(byte[] inArray, int offset, int length)
Definition Convert.cs:2693
static int ToBase64CharArray(byte[] inArray, int offsetIn, int length, char[] outArray, int offsetOut)
Definition Convert.cs:2741
static int ToInt32(uint value)
Definition Convert.cs:1375
static short ToInt16(uint value)
Definition Convert.cs:1105
static uint ToUInt32(int value)
Definition Convert.cs:1538
static string ToString(short value)
Definition Convert.cs:2385
static unsafe bool TryToBase64Chars(ReadOnlySpan< byte > bytes, Span< char > chars, out int charsWritten, Base64FormattingOptions options=Base64FormattingOptions.None)
Definition Convert.cs:2799
static string ToString(ulong value, IFormatProvider? provider)
Definition Convert.cs:2446
static ulong ToUInt64(object? value, IFormatProvider? provider)
Definition Convert.cs:1748
static char ToChar(DateTime value)
Definition Convert.cs:739
static int ToInt32(double value)
Definition Convert.cs:1413
static bool TryDecodeFromUtf16(ReadOnlySpan< char > utf16, Span< byte > bytes, out int consumed, out int written)
Definition Convert.cs:79
static long ToInt64(string? value, int fromBase)
Definition Convert.cs:2612
static float ToSingle(object? value)
Definition Convert.cs:1881
static int ToInt32(object? value)
Definition Convert.cs:1320
static int ToInt32(int value)
Definition Convert.cs:1384
static string ToString(long value)
Definition Convert.cs:2429
static DateTime ToDateTime(uint value)
Definition Convert.cs:2280
static decimal ToDecimal(object? value, IFormatProvider? provider)
Definition Convert.cs:2110
static DateTime ToDateTime(DateTime value)
Definition Convert.cs:2211
static DateTime ToDateTime(decimal value)
Definition Convert.cs:2316
static sbyte ToSByte(object? value, IFormatProvider? provider)
Definition Convert.cs:755
static DateTime ToDateTime(sbyte value)
Definition Convert.cs:2253
static int ToInt32(bool value)
Definition Convert.cs:1338
static bool ToBoolean(long value)
Definition Convert.cs:569
static string ToString(uint value)
Definition Convert.cs:2418
static void ThrowInt64OverflowException()
Definition Convert.cs:497
static short ToInt16(string? value, IFormatProvider? provider)
Definition Convert.cs:1162
static ulong ToUInt64(string? value)
Definition Convert.cs:1856
static char ToChar(ulong value)
Definition Convert.cs:697
static bool ToBoolean(ushort value)
Definition Convert.cs:553
static ushort ToUInt16(decimal value)
Definition Convert.cs:1289
static short ToInt16(sbyte value)
Definition Convert.cs:1075
static bool ToBoolean(bool value)
Definition Convert.cs:526
static string ToString(byte value, IFormatProvider? provider)
Definition Convert.cs:2380
static string ToString(float value, IFormatProvider? provider)
Definition Convert.cs:2456
static string ToString(ushort value)
Definition Convert.cs:2396
static ulong ToUInt64(int value)
Definition Convert.cs:1806
static unsafe string ToBase64String(ReadOnlySpan< byte > bytes, Base64FormattingOptions options=Base64FormattingOptions.None)
Definition Convert.cs:2719
static string ToString(char value)
Definition Convert.cs:2353
static char ToChar(bool value)
Definition Convert.cs:636
static bool ToBoolean(short value)
Definition Convert.cs:547
static decimal ToDecimal(ulong value)
Definition Convert.cs:2163
static void ThrowByteOverflowException()
Definition Convert.cs:461
static string ToString(sbyte value)
Definition Convert.cs:2364
static ulong ToUInt64(ulong value)
Definition Convert.cs:1832
static ushort ToUInt16(string? value, IFormatProvider? provider)
Definition Convert.cs:1305
static readonly char[] base64Table
Definition Convert.cs:36
static int ToInt32(decimal value)
Definition Convert.cs:1441
static char ToChar(decimal value)
Definition Convert.cs:734
static int ToInt32(object? value, IFormatProvider? provider)
Definition Convert.cs:1329
static ReadOnlySpan< sbyte > DecodingMap
Definition Convert.cs:49
static string ToString(double value, IFormatProvider? provider)
Definition Convert.cs:2466
static ? string ToString(string? value, IFormatProvider? provider)
Definition Convert.cs:2498
static double ToDouble(ushort value)
Definition Convert.cs:2031
static decimal ToDecimal(decimal value)
Definition Convert.cs:2196
static long ToInt64(long value)
Definition Convert.cs:1694
static string ToString(double value)
Definition Convert.cs:2461
static string ToString(short value, IFormatProvider? provider)
Definition Convert.cs:2390
static void ThrowSByteOverflowException()
Definition Convert.cs:467
static ulong ToUInt64(float value)
Definition Convert.cs:1838
static int Decode(ref char encodedChars, ref sbyte decodingMap)
Definition Convert.cs:172
static ushort ToUInt16(short value)
Definition Convert.cs:1229
static double ToDouble(byte value)
Definition Convert.cs:2015
static short ToInt16(int value)
Definition Convert.cs:1095
static bool TryFromBase64String(string s, Span< byte > bytes, out int bytesWritten)
Definition Convert.cs:2916
static ? object ChangeType(object? value, TypeCode typeCode, IFormatProvider? provider)
Definition Convert.cs:235
static decimal ToDecimal(byte value)
Definition Convert.cs:2125
static double ToDouble(bool value)
Definition Convert.cs:2091
static string ToHexString(byte[] inArray)
Definition Convert.cs:3159
static short ToInt16(string? value)
Definition Convert.cs:1153
static float ToSingle(short value)
Definition Convert.cs:1915
static uint ToUInt32(byte value)
Definition Convert.cs:1516
static int ToBase64_CalculateAndValidateOutputLength(int inputLength, bool insertLineBreaks)
Definition Convert.cs:2881
static long ToInt64(uint value)
Definition Convert.cs:1679
static short ToInt16(double value)
Definition Convert.cs:1143
static uint ToUInt32(double value)
Definition Convert.cs:1576
static decimal ToDecimal(long value)
Definition Convert.cs:2157
static ushort ToUInt16(object? value, IFormatProvider? provider)
Definition Convert.cs:1187
static byte ToByte(char value)
Definition Convert.cs:932
static ushort ToUInt16(string? value)
Definition Convert.cs:1295
static decimal ToDecimal(char value)
Definition Convert.cs:2130
static DateTime ToDateTime(object? value, IFormatProvider? provider)
Definition Convert.cs:2225
static long ToInt64(sbyte value)
Definition Convert.cs:1652
static uint ToUInt32(string? value, int fromBase)
Definition Convert.cs:2599
static byte ToByte(sbyte value)
Definition Convert.cs:942
static int ToInt32(ushort value)
Definition Convert.cs:1369
static bool ToBoolean(char value)
Definition Convert.cs:537
static readonly Type EnumType
Definition Convert.cs:34
static uint ToUInt32(ushort value)
Definition Convert.cs:1532
static long ToInt64(object? value, IFormatProvider? provider)
Definition Convert.cs:1632
static DateTime ToDateTime(string? value)
Definition Convert.cs:2234
static bool ToBoolean([NotNullWhen(true)] object? value, IFormatProvider? provider)
Definition Convert.cs:517
static char ToChar(ushort value)
Definition Convert.cs:671
static short ToInt16(long value)
Definition Convert.cs:1119
static long ToInt64(decimal value)
Definition Convert.cs:1709
static short ToInt16(object? value)
Definition Convert.cs:1038
static DateTime ToDateTime(short value)
Definition Convert.cs:2263
static long ToInt64(DateTime value)
Definition Convert.cs:1732
static string ToString(ulong value)
Definition Convert.cs:2440
static sbyte ToSByte(byte value)
Definition Convert.cs:791
static uint ToUInt32(short value)
Definition Convert.cs:1522
static char ToChar(object? value, IFormatProvider? provider)
Definition Convert.cs:627
static float ToSingle(double value)
Definition Convert.cs:1953
static bool ToBoolean(byte value)
Definition Convert.cs:542
static string ToString(byte value)
Definition Convert.cs:2375
static ushort ToUInt16(sbyte value)
Definition Convert.cs:1213
static bool ToBoolean(int value)
Definition Convert.cs:558
static ushort ToUInt16(DateTime value)
Definition Convert.cs:1315
static ulong ToUInt64(char value)
Definition Convert.cs:1768
static ulong ToUInt64(short value)
Definition Convert.cs:1790
static short ToInt16(ulong value)
Definition Convert.cs:1129
static sbyte ToSByte(decimal value)
Definition Convert.cs:873
static char ToChar(uint value)
Definition Convert.cs:682
static byte ToByte(ushort value)
Definition Convert.cs:961
static decimal ToDecimal(DateTime value)
Definition Convert.cs:2206
static string ToString(int value, IFormatProvider? provider)
Definition Convert.cs:2412
static byte ToByte(object? value)
Definition Convert.cs:900
static DateTime ToDateTime(float value)
Definition Convert.cs:2306
static int ToInt32(string? value, int fromBase)
Definition Convert.cs:2585
static unsafe int ToBase64CharArray(byte[] inArray, int offsetIn, int length, char[] outArray, int offsetOut, Base64FormattingOptions options)
Definition Convert.cs:2746
static uint ToUInt32(DateTime value)
Definition Convert.cs:1618
static uint ToUInt32(object? value)
Definition Convert.cs:1470
static sbyte ToSByte(long value)
Definition Convert.cs:841
static char ToChar(short value)
Definition Convert.cs:661
static ulong ToUInt64(object? value)
Definition Convert.cs:1738
static byte ToByte(double value)
Definition Convert.cs:1005
static char ToChar(char value)
Definition Convert.cs:641
static float ToSingle(byte value)
Definition Convert.cs:1905
static int ToInt32(float value)
Definition Convert.cs:1408
static double ToDouble(char value)
Definition Convert.cs:2025
static sbyte ToSByte(string? value)
Definition Convert.cs:879
static bool IsSpace(this char c)
Definition Convert.cs:3007
static long ToInt64(byte value)
Definition Convert.cs:1657
static void ThrowCharOverflowException()
Definition Convert.cs:455
static sbyte ToSByte(ulong value)
Definition Convert.cs:851
static char ToChar(object? value)
Definition Convert.cs:618
static string ToString(bool value, IFormatProvider? provider)
Definition Convert.cs:2348
static long ToInt64(ulong value)
Definition Convert.cs:1685
static char ToChar(float value)
Definition Convert.cs:724
static float ToSingle(char value)
Definition Convert.cs:1910
static uint ToUInt32(bool value)
Definition Convert.cs:1490
static DateTime ToDateTime(bool value)
Definition Convert.cs:2296
static byte ToByte(uint value)
Definition Convert.cs:976
static double ToDouble(object? value, IFormatProvider? provider)
Definition Convert.cs:2000
static ushort ToUInt16(object? value)
Definition Convert.cs:1177
static byte ToByte(string? value)
Definition Convert.cs:1015
static uint ToUInt32(float value)
Definition Convert.cs:1570
static char ToChar(byte value)
Definition Convert.cs:656
static string ToString(byte value, int toBase)
Definition Convert.cs:2639
static long ToInt64(bool value)
Definition Convert.cs:1641
static DateTime ToDateTime(char value)
Definition Convert.cs:2301
static void ThrowUInt64OverflowException()
Definition Convert.cs:503
static short ToInt16(string? value, int fromBase)
Definition Convert.cs:2544
static short ToInt16(bool value)
Definition Convert.cs:1056
static sbyte ToSByte(int value)
Definition Convert.cs:821
static ? object ChangeType(object? value, TypeCode typeCode)
Definition Convert.cs:229
static readonly Type[] ConvertTypes
Definition Convert.cs:11
static sbyte ToSByte(object? value)
Definition Convert.cs:745
static double ToDouble(long value)
Definition Convert.cs:2047
static bool ToBoolean([NotNullWhen(true)] string? value, IFormatProvider? provider)
Definition Convert.cs:589
static long ToInt64(char value)
Definition Convert.cs:1646
static ushort ToUInt16(double value)
Definition Convert.cs:1283
static short ToInt16(float value)
Definition Convert.cs:1138
static double ToDouble(double value)
Definition Convert.cs:2063
static bool ToBoolean(double value)
Definition Convert.cs:603
static double ToDouble(uint value)
Definition Convert.cs:2042
static decimal ToDecimal(string? value, IFormatProvider? provider)
Definition Convert.cs:2187
static string ToBase64String(byte[] inArray)
Definition Convert.cs:2675
static int ToInt32(long value)
Definition Convert.cs:1389
static unsafe byte[] FromBase64CharPtr(char *inputPtr, int inputLength)
Definition Convert.cs:3044
static sbyte ToSByte(short value)
Definition Convert.cs:801
static ushort ToUInt16(long value)
Definition Convert.cs:1261
static double ToDouble(int value)
Definition Convert.cs:2036
static long ToInt64(string? value, IFormatProvider? provider)
Definition Convert.cs:1723
static char ToChar(double value)
Definition Convert.cs:729
static DateTime ToDateTime(object? value)
Definition Convert.cs:2216
static string ToString(long value, IFormatProvider? provider)
Definition Convert.cs:2434
static ushort ToUInt16(string? value, int fromBase)
Definition Convert.cs:2567
static int ToInt32(sbyte value)
Definition Convert.cs:1353
static int ToInt32(ulong value)
Definition Convert.cs:1399
static char ToChar(string value, IFormatProvider? provider)
Definition Convert.cs:711
static int ToInt32(short value)
Definition Convert.cs:1363
static decimal ToDecimal(uint value)
Definition Convert.cs:2152
static bool ToBoolean(uint value)
Definition Convert.cs:564
static double ToDouble(object? value)
Definition Convert.cs:1991
static bool ToBoolean([NotNullWhen(true)] object? value)
Definition Convert.cs:508
static int ToInt32(char value)
Definition Convert.cs:1347
static int ToInt32(byte value)
Definition Convert.cs:1358
static float ToSingle(int value)
Definition Convert.cs:1926
static short ToInt16(decimal value)
Definition Convert.cs:1148
static float ToSingle(object? value, IFormatProvider? provider)
Definition Convert.cs:1890
static float ToSingle(float value)
Definition Convert.cs:1948
static char ToChar(long value)
Definition Convert.cs:691
static uint ToUInt32(uint value)
Definition Convert.cs:1548
static bool ToBoolean(decimal value)
Definition Convert.cs:608
static ? string ToString(object? value, IFormatProvider? provider)
Definition Convert.cs:2326
static unsafe byte[] FromBase64CharArray(char[] inArray, int offset, int length)
Definition Convert.cs:3016
static TypeCode GetTypeCode(object? value)
Definition Convert.cs:202
static DateTime ToDateTime(double value)
Definition Convert.cs:2311
static byte[] FromHexString(ReadOnlySpan< char > chars)
Definition Convert.cs:3141
static string ToString(sbyte value, IFormatProvider? provider)
Definition Convert.cs:2370
static long ToInt64(int value)
Definition Convert.cs:1673
static double ToDouble(sbyte value)
Definition Convert.cs:2010
static byte ToByte(ulong value)
Definition Convert.cs:991
static ulong ToUInt64(sbyte value)
Definition Convert.cs:1774
static string ToString(decimal value, IFormatProvider? provider)
Definition Convert.cs:2476
static short ToInt16(short value)
Definition Convert.cs:1114
static void ThrowUInt16OverflowException()
Definition Convert.cs:479
static DateTime ToDateTime(byte value)
Definition Convert.cs:2258
static float ToSingle(sbyte value)
Definition Convert.cs:1900
static object DefaultToType(IConvertible value, Type targetType, IFormatProvider provider)
Definition Convert.cs:269
static void ThrowInt16OverflowException()
Definition Convert.cs:473
static bool TryFromBase64Chars(ReadOnlySpan< char > chars, Span< byte > bytes, out int bytesWritten)
Definition Convert.cs:2925
static ? object ChangeType(object? value, Type conversionType, IFormatProvider? provider)
Definition Convert.cs:365
static float ToSingle(string? value)
Definition Convert.cs:1963
static ushort ToUInt16(uint value)
Definition Convert.cs:1251
static DateTime ToDateTime(int value)
Definition Convert.cs:2274
static long ToInt64(ushort value)
Definition Convert.cs:1668
static byte ToByte(byte value)
Definition Convert.cs:927
static char ToChar(int value)
Definition Convert.cs:676
static byte ToByte(string? value, int fromBase)
Definition Convert.cs:2503
static short ToInt16(byte value)
Definition Convert.cs:1080
static char ToChar(string value)
Definition Convert.cs:706
static unsafe int ConvertToBase64Array(char *outChars, byte *inData, int offset, int length, bool insertLineBreaks)
Definition Convert.cs:2827
static DateTime ToDateTime(ushort value)
Definition Convert.cs:2269
static ulong ToUInt64(uint value)
Definition Convert.cs:1816
static string ToString(uint value, IFormatProvider? provider)
Definition Convert.cs:2424
static ulong ToUInt64(double value)
Definition Convert.cs:1844
static bool ToBoolean(ulong value)
Definition Convert.cs:575
static decimal ToDecimal(string? value)
Definition Convert.cs:2178
static decimal ToDecimal(short value)
Definition Convert.cs:2135
static ulong ToUInt64(bool value)
Definition Convert.cs:1758
static ushort ToUInt16(ulong value)
Definition Convert.cs:1267
static ulong ToUInt64(byte value)
Definition Convert.cs:1784
static byte ToByte(string? value, IFormatProvider? provider)
Definition Convert.cs:1024
static ushort ToUInt16(int value)
Definition Convert.cs:1239
static string ToString(bool value)
Definition Convert.cs:2343
static float ToSingle(ushort value)
Definition Convert.cs:1921
static short ToInt16(object? value, IFormatProvider? provider)
Definition Convert.cs:1047
static short ToInt16(DateTime value)
Definition Convert.cs:1171
static float ToSingle(long value)
Definition Convert.cs:1937
static void WriteThreeLowOrderBytes(ref byte destination, int value)
Definition Convert.cs:195
static decimal ToDecimal(double value)
Definition Convert.cs:2173
static unsafe byte[] FromBase64String(string s)
Definition Convert.cs:2904
static void ThrowUInt32OverflowException()
Definition Convert.cs:491
static readonly DBNull Value
Definition DBNull.cs:8
Definition GC.cs:8
static CultureInfo CurrentCulture
static bool TryDecodeFromUtf16(ReadOnlySpan< char > chars, Span< byte > bytes)
static unsafe string ToString(ReadOnlySpan< byte > bytes, Casing casing=Casing.Upper)
static decimal Round(decimal d)
Definition Math.cs:1096
static int DivRem(int a, int b, out int result)
Definition Math.cs:329
static unsafe string LongToString(long n, int radix, int width, char paddingChar, int flags)
static long StringToLong(ReadOnlySpan< char > s, int radix, int flags)
static unsafe string IntToString(int n, int radix, int width, char paddingChar, int flags)
static int StringToInt(ReadOnlySpan< char > s, int radix, int flags)
static string ArgumentOutOfRange_Index
Definition SR.cs:30
static string Format_BadHexLength
Definition SR.cs:1336
static string Overflow_Int16
Definition SR.cs:1770
static string Overflow_UInt16
Definition SR.cs:1786
static string Arg_UnknownTypeCode
Definition SR.cs:446
static string InvalidCast_FromTo
Definition SR.cs:1392
static string Overflow_Int32
Definition SR.cs:1772
static string Overflow_SByte
Definition SR.cs:1780
static string InvalidCast_CannotCastNullToValueType
Definition SR.cs:1382
static string Overflow_UInt64
Definition SR.cs:1790
static string Arg_EnumIllegalVal
Definition SR.cs:144
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string Arg_InvalidBase
Definition SR.cs:196
static string Format_BadBase64Char
Definition SR.cs:1320
static string Overflow_Int64
Definition SR.cs:1774
static string Format_NeedSingleChar
Definition SR.cs:1356
static string InvalidCast_IConvertible
Definition SR.cs:1394
static string Overflow_Byte
Definition SR.cs:1760
static string InvalidCast_Empty
Definition SR.cs:1388
static string InvalidCast_DBNull
Definition SR.cs:1386
static string ArgumentOutOfRange_GenericPositive
Definition SR.cs:1018
static string Overflow_Char
Definition SR.cs:1762
static string ArgumentOutOfRange_OffsetOut
Definition SR.cs:1086
static string ArgumentOutOfRange_OffsetLength
Definition SR.cs:1084
static string Overflow_UInt32
Definition SR.cs:1788
static string ArgumentOutOfRange_InputTooLarge
Definition SR.cs:1038
static string Format_BadHexChar
Definition SR.cs:1334
Definition SR.cs:7
static void ThrowArgumentNullException(string name)
bool IsValueType
Definition Type.cs:234
string? FullName
Definition Type.cs:47
TypeCode
Definition TypeCode.cs:4
static readonly DateTime MinValue
Definition DateTime.cs:35
static DateTime Parse(string s)
Definition DateTime.cs:919
Span< T > Slice(int start)
Definition Span.cs:271
int Length
Definition Span.cs:70