mscorlib(4.0.0.0) API with additions
Convert.cs
3 using System.Security;
4 using System.Threading;
5 
6 namespace System
7 {
9  [__DynamicallyInvokable]
10  public static class Convert
11  {
12  internal static readonly RuntimeType[] ConvertTypes = new RuntimeType[19]
13  {
14  (RuntimeType)typeof(Empty),
15  (RuntimeType)typeof(object),
16  (RuntimeType)typeof(DBNull),
17  (RuntimeType)typeof(bool),
18  (RuntimeType)typeof(char),
19  (RuntimeType)typeof(sbyte),
20  (RuntimeType)typeof(byte),
21  (RuntimeType)typeof(short),
22  (RuntimeType)typeof(ushort),
23  (RuntimeType)typeof(int),
24  (RuntimeType)typeof(uint),
25  (RuntimeType)typeof(long),
26  (RuntimeType)typeof(ulong),
27  (RuntimeType)typeof(float),
28  (RuntimeType)typeof(double),
29  (RuntimeType)typeof(decimal),
30  (RuntimeType)typeof(DateTime),
31  (RuntimeType)typeof(object),
32  (RuntimeType)typeof(string)
33  };
34 
35  private static readonly RuntimeType EnumType = (RuntimeType)typeof(Enum);
36 
37  internal static readonly char[] base64Table = new char[65]
38  {
39  'A',
40  'B',
41  'C',
42  'D',
43  'E',
44  'F',
45  'G',
46  'H',
47  'I',
48  'J',
49  'K',
50  'L',
51  'M',
52  'N',
53  'O',
54  'P',
55  'Q',
56  'R',
57  'S',
58  'T',
59  'U',
60  'V',
61  'W',
62  'X',
63  'Y',
64  'Z',
65  'a',
66  'b',
67  'c',
68  'd',
69  'e',
70  'f',
71  'g',
72  'h',
73  'i',
74  'j',
75  'k',
76  'l',
77  'm',
78  'n',
79  'o',
80  'p',
81  'q',
82  'r',
83  's',
84  't',
85  'u',
86  'v',
87  'w',
88  'x',
89  'y',
90  'z',
91  '0',
92  '1',
93  '2',
94  '3',
95  '4',
96  '5',
97  '6',
98  '7',
99  '8',
100  '9',
101  '+',
102  '/',
103  '='
104  };
105 
106  private const int base64LineBreakPosition = 76;
107 
109  public static readonly object DBNull = System.DBNull.Value;
110 
114  [__DynamicallyInvokable]
115  public static TypeCode GetTypeCode(object value)
116  {
117  if (value == null)
118  {
119  return TypeCode.Empty;
120  }
121  return (value as IConvertible)?.GetTypeCode() ?? TypeCode.Object;
122  }
123 
128  public static bool IsDBNull(object value)
129  {
130  if (value == System.DBNull.Value)
131  {
132  return true;
133  }
134  IConvertible convertible = value as IConvertible;
135  if (convertible == null)
136  {
137  return false;
138  }
139  return convertible.GetTypeCode() == TypeCode.DBNull;
140  }
141 
155  public static object ChangeType(object value, TypeCode typeCode)
156  {
157  return ChangeType(value, typeCode, Thread.CurrentThread.CurrentCulture);
158  }
159 
174  [__DynamicallyInvokable]
175  public static object ChangeType(object value, TypeCode typeCode, IFormatProvider provider)
176  {
177  if (value == null && (typeCode == TypeCode.Empty || typeCode == TypeCode.String || typeCode == TypeCode.Object))
178  {
179  return null;
180  }
181  IConvertible convertible = value as IConvertible;
182  if (convertible == null)
183  {
184  throw new InvalidCastException(Environment.GetResourceString("InvalidCast_IConvertible"));
185  }
186  switch (typeCode)
187  {
188  case TypeCode.Boolean:
189  return convertible.ToBoolean(provider);
190  case TypeCode.Char:
191  return convertible.ToChar(provider);
192  case TypeCode.SByte:
193  return convertible.ToSByte(provider);
194  case TypeCode.Byte:
195  return convertible.ToByte(provider);
196  case TypeCode.Int16:
197  return convertible.ToInt16(provider);
198  case TypeCode.UInt16:
199  return convertible.ToUInt16(provider);
200  case TypeCode.Int32:
201  return convertible.ToInt32(provider);
202  case TypeCode.UInt32:
203  return convertible.ToUInt32(provider);
204  case TypeCode.Int64:
205  return convertible.ToInt64(provider);
206  case TypeCode.UInt64:
207  return convertible.ToUInt64(provider);
208  case TypeCode.Single:
209  return convertible.ToSingle(provider);
210  case TypeCode.Double:
211  return convertible.ToDouble(provider);
212  case TypeCode.Decimal:
213  return convertible.ToDecimal(provider);
214  case TypeCode.DateTime:
215  return convertible.ToDateTime(provider);
216  case TypeCode.String:
217  return convertible.ToString(provider);
218  case TypeCode.Object:
219  return value;
220  case TypeCode.DBNull:
221  throw new InvalidCastException(Environment.GetResourceString("InvalidCast_DBNull"));
222  case TypeCode.Empty:
223  throw new InvalidCastException(Environment.GetResourceString("InvalidCast_Empty"));
224  default:
225  throw new ArgumentException(Environment.GetResourceString("Arg_UnknownTypeCode"));
226  }
227  }
228 
229  internal static object DefaultToType(IConvertible value, Type targetType, IFormatProvider provider)
230  {
231  if (targetType == null)
232  {
233  throw new ArgumentNullException("targetType");
234  }
235  RuntimeType left = targetType as RuntimeType;
236  if (left != null)
237  {
238  if (value.GetType() == targetType)
239  {
240  return value;
241  }
242  if (left == ConvertTypes[3])
243  {
244  return value.ToBoolean(provider);
245  }
246  if (left == ConvertTypes[4])
247  {
248  return value.ToChar(provider);
249  }
250  if (left == ConvertTypes[5])
251  {
252  return value.ToSByte(provider);
253  }
254  if (left == ConvertTypes[6])
255  {
256  return value.ToByte(provider);
257  }
258  if (left == ConvertTypes[7])
259  {
260  return value.ToInt16(provider);
261  }
262  if (left == ConvertTypes[8])
263  {
264  return value.ToUInt16(provider);
265  }
266  if (left == ConvertTypes[9])
267  {
268  return value.ToInt32(provider);
269  }
270  if (left == ConvertTypes[10])
271  {
272  return value.ToUInt32(provider);
273  }
274  if (left == ConvertTypes[11])
275  {
276  return value.ToInt64(provider);
277  }
278  if (left == ConvertTypes[12])
279  {
280  return value.ToUInt64(provider);
281  }
282  if (left == ConvertTypes[13])
283  {
284  return value.ToSingle(provider);
285  }
286  if (left == ConvertTypes[14])
287  {
288  return value.ToDouble(provider);
289  }
290  if (left == ConvertTypes[15])
291  {
292  return value.ToDecimal(provider);
293  }
294  if (left == ConvertTypes[16])
295  {
296  return value.ToDateTime(provider);
297  }
298  if (left == ConvertTypes[18])
299  {
300  return value.ToString(provider);
301  }
302  if (left == ConvertTypes[1])
303  {
304  return value;
305  }
306  if (left == EnumType)
307  {
308  return (Enum)value;
309  }
310  if (left == ConvertTypes[2])
311  {
312  throw new InvalidCastException(Environment.GetResourceString("InvalidCast_DBNull"));
313  }
314  if (left == ConvertTypes[0])
315  {
316  throw new InvalidCastException(Environment.GetResourceString("InvalidCast_Empty"));
317  }
318  }
319  throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromTo", value.GetType().FullName, targetType.FullName));
320  }
321 
335  [__DynamicallyInvokable]
336  public static object ChangeType(object value, Type conversionType)
337  {
338  return ChangeType(value, conversionType, Thread.CurrentThread.CurrentCulture);
339  }
340 
356  [__DynamicallyInvokable]
357  public static object ChangeType(object value, Type conversionType, IFormatProvider provider)
358  {
359  if (conversionType == null)
360  {
361  throw new ArgumentNullException("conversionType");
362  }
363  if (value == null)
364  {
365  if (conversionType.IsValueType)
366  {
367  throw new InvalidCastException(Environment.GetResourceString("InvalidCast_CannotCastNullToValueType"));
368  }
369  return null;
370  }
371  IConvertible convertible = value as IConvertible;
372  if (convertible == null)
373  {
374  if (value.GetType() == conversionType)
375  {
376  return value;
377  }
378  throw new InvalidCastException(Environment.GetResourceString("InvalidCast_IConvertible"));
379  }
380  RuntimeType left = conversionType as RuntimeType;
381  if (left == ConvertTypes[3])
382  {
383  return convertible.ToBoolean(provider);
384  }
385  if (left == ConvertTypes[4])
386  {
387  return convertible.ToChar(provider);
388  }
389  if (left == ConvertTypes[5])
390  {
391  return convertible.ToSByte(provider);
392  }
393  if (left == ConvertTypes[6])
394  {
395  return convertible.ToByte(provider);
396  }
397  if (left == ConvertTypes[7])
398  {
399  return convertible.ToInt16(provider);
400  }
401  if (left == ConvertTypes[8])
402  {
403  return convertible.ToUInt16(provider);
404  }
405  if (left == ConvertTypes[9])
406  {
407  return convertible.ToInt32(provider);
408  }
409  if (left == ConvertTypes[10])
410  {
411  return convertible.ToUInt32(provider);
412  }
413  if (left == ConvertTypes[11])
414  {
415  return convertible.ToInt64(provider);
416  }
417  if (left == ConvertTypes[12])
418  {
419  return convertible.ToUInt64(provider);
420  }
421  if (left == ConvertTypes[13])
422  {
423  return convertible.ToSingle(provider);
424  }
425  if (left == ConvertTypes[14])
426  {
427  return convertible.ToDouble(provider);
428  }
429  if (left == ConvertTypes[15])
430  {
431  return convertible.ToDecimal(provider);
432  }
433  if (left == ConvertTypes[16])
434  {
435  return convertible.ToDateTime(provider);
436  }
437  if (left == ConvertTypes[18])
438  {
439  return convertible.ToString(provider);
440  }
441  if (left == ConvertTypes[1])
442  {
443  return value;
444  }
445  return convertible.ToType(conversionType, provider);
446  }
447 
456  [__DynamicallyInvokable]
457  public static bool ToBoolean(object value)
458  {
459  if (value != null)
460  {
461  return ((IConvertible)value).ToBoolean(null);
462  }
463  return false;
464  }
465 
475  [__DynamicallyInvokable]
476  public static bool ToBoolean(object value, IFormatProvider provider)
477  {
478  if (value != null)
479  {
480  return ((IConvertible)value).ToBoolean(provider);
481  }
482  return false;
483  }
484 
489  [__DynamicallyInvokable]
490  public static bool ToBoolean(bool value)
491  {
492  return value;
493  }
494 
499  [CLSCompliant(false)]
500  [__DynamicallyInvokable]
501  public static bool ToBoolean(sbyte value)
502  {
503  return value != 0;
504  }
505 
510  public static bool ToBoolean(char value)
511  {
512  return ((IConvertible)value).ToBoolean((IFormatProvider)null);
513  }
514 
519  [__DynamicallyInvokable]
520  public static bool ToBoolean(byte value)
521  {
522  return value != 0;
523  }
524 
529  [__DynamicallyInvokable]
530  public static bool ToBoolean(short value)
531  {
532  return value != 0;
533  }
534 
539  [CLSCompliant(false)]
540  [__DynamicallyInvokable]
541  public static bool ToBoolean(ushort value)
542  {
543  return value != 0;
544  }
545 
550  [__DynamicallyInvokable]
551  public static bool ToBoolean(int value)
552  {
553  return value != 0;
554  }
555 
560  [CLSCompliant(false)]
561  [__DynamicallyInvokable]
562  public static bool ToBoolean(uint value)
563  {
564  return value != 0;
565  }
566 
571  [__DynamicallyInvokable]
572  public static bool ToBoolean(long value)
573  {
574  return value != 0;
575  }
576 
581  [CLSCompliant(false)]
582  [__DynamicallyInvokable]
583  public static bool ToBoolean(ulong value)
584  {
585  return value != 0;
586  }
587 
594  [__DynamicallyInvokable]
595  public static bool ToBoolean(string value)
596  {
597  if (value == null)
598  {
599  return false;
600  }
601  return bool.Parse(value);
602  }
603 
611  [__DynamicallyInvokable]
612  public static bool ToBoolean(string value, IFormatProvider provider)
613  {
614  if (value == null)
615  {
616  return false;
617  }
618  return bool.Parse(value);
619  }
620 
625  [__DynamicallyInvokable]
626  public static bool ToBoolean(float value)
627  {
628  return value != 0f;
629  }
630 
635  [__DynamicallyInvokable]
636  public static bool ToBoolean(double value)
637  {
638  return value != 0.0;
639  }
640 
645  [__DynamicallyInvokable]
646  public static bool ToBoolean(decimal value)
647  {
648  return value != decimal.Zero;
649  }
650 
655  public static bool ToBoolean(DateTime value)
656  {
657  return ((IConvertible)value).ToBoolean((IFormatProvider)null);
658  }
659 
669  [__DynamicallyInvokable]
670  public static char ToChar(object value)
671  {
672  if (value != null)
673  {
674  return ((IConvertible)value).ToChar(null);
675  }
676  return '\0';
677  }
678 
689  [__DynamicallyInvokable]
690  public static char ToChar(object value, IFormatProvider provider)
691  {
692  if (value != null)
693  {
694  return ((IConvertible)value).ToChar(provider);
695  }
696  return '\0';
697  }
698 
703  public static char ToChar(bool value)
704  {
705  return ((IConvertible)value).ToChar((IFormatProvider)null);
706  }
707 
712  public static char ToChar(char value)
713  {
714  return value;
715  }
716 
722  [CLSCompliant(false)]
723  [__DynamicallyInvokable]
724  public static char ToChar(sbyte value)
725  {
726  if (value < 0)
727  {
728  throw new OverflowException(Environment.GetResourceString("Overflow_Char"));
729  }
730  return (char)value;
731  }
732 
736  [__DynamicallyInvokable]
737  public static char ToChar(byte value)
738  {
739  return (char)value;
740  }
741 
747  [__DynamicallyInvokable]
748  public static char ToChar(short value)
749  {
750  if (value < 0)
751  {
752  throw new OverflowException(Environment.GetResourceString("Overflow_Char"));
753  }
754  return (char)value;
755  }
756 
760  [CLSCompliant(false)]
761  [__DynamicallyInvokable]
762  public static char ToChar(ushort value)
763  {
764  return (char)value;
765  }
766 
772  [__DynamicallyInvokable]
773  public static char ToChar(int value)
774  {
775  if (value < 0 || value > 65535)
776  {
777  throw new OverflowException(Environment.GetResourceString("Overflow_Char"));
778  }
779  return (char)value;
780  }
781 
787  [CLSCompliant(false)]
788  [__DynamicallyInvokable]
789  public static char ToChar(uint value)
790  {
791  if (value > 65535)
792  {
793  throw new OverflowException(Environment.GetResourceString("Overflow_Char"));
794  }
795  return (char)value;
796  }
797 
803  [__DynamicallyInvokable]
804  public static char ToChar(long value)
805  {
806  if (value < 0 || value > 65535)
807  {
808  throw new OverflowException(Environment.GetResourceString("Overflow_Char"));
809  }
810  return (char)value;
811  }
812 
818  [CLSCompliant(false)]
819  [__DynamicallyInvokable]
820  public static char ToChar(ulong value)
821  {
822  if (value > 65535)
823  {
824  throw new OverflowException(Environment.GetResourceString("Overflow_Char"));
825  }
826  return (char)value;
827  }
828 
835  [__DynamicallyInvokable]
836  public static char ToChar(string value)
837  {
838  return ToChar(value, null);
839  }
840 
848  [__DynamicallyInvokable]
849  public static char ToChar(string value, IFormatProvider provider)
850  {
851  if (value == null)
852  {
853  throw new ArgumentNullException("value");
854  }
855  if (value.Length != 1)
856  {
857  throw new FormatException(Environment.GetResourceString("Format_NeedSingleChar"));
858  }
859  return value[0];
860  }
861 
866  public static char ToChar(float value)
867  {
868  return ((IConvertible)value).ToChar((IFormatProvider)null);
869  }
870 
875  public static char ToChar(double value)
876  {
877  return ((IConvertible)value).ToChar((IFormatProvider)null);
878  }
879 
884  public static char ToChar(decimal value)
885  {
886  return ((IConvertible)value).ToChar((IFormatProvider)null);
887  }
888 
893  public static char ToChar(DateTime value)
894  {
895  return ((IConvertible)value).ToChar((IFormatProvider)null);
896  }
897 
907  [CLSCompliant(false)]
908  [__DynamicallyInvokable]
909  public static sbyte ToSByte(object value)
910  {
911  if (value != null)
912  {
913  return ((IConvertible)value).ToSByte(null);
914  }
915  return 0;
916  }
917 
928  [CLSCompliant(false)]
929  [__DynamicallyInvokable]
930  public static sbyte ToSByte(object value, IFormatProvider provider)
931  {
932  if (value != null)
933  {
934  return ((IConvertible)value).ToSByte(provider);
935  }
936  return 0;
937  }
938 
942  [CLSCompliant(false)]
943  [__DynamicallyInvokable]
944  public static sbyte ToSByte(bool value)
945  {
946  if (!value)
947  {
948  return 0;
949  }
950  return 1;
951  }
952 
957  [CLSCompliant(false)]
958  [__DynamicallyInvokable]
959  public static sbyte ToSByte(sbyte value)
960  {
961  return value;
962  }
963 
969  [CLSCompliant(false)]
970  [__DynamicallyInvokable]
971  public static sbyte ToSByte(char value)
972  {
973  if (value > '\u007f')
974  {
975  throw new OverflowException(Environment.GetResourceString("Overflow_SByte"));
976  }
977  return (sbyte)value;
978  }
979 
985  [CLSCompliant(false)]
986  [__DynamicallyInvokable]
987  public static sbyte ToSByte(byte value)
988  {
989  if (value > 127)
990  {
991  throw new OverflowException(Environment.GetResourceString("Overflow_SByte"));
992  }
993  return (sbyte)value;
994  }
995 
1001  [CLSCompliant(false)]
1002  [__DynamicallyInvokable]
1003  public static sbyte ToSByte(short value)
1004  {
1005  if (value < -128 || value > 127)
1006  {
1007  throw new OverflowException(Environment.GetResourceString("Overflow_SByte"));
1008  }
1009  return (sbyte)value;
1010  }
1011 
1017  [CLSCompliant(false)]
1018  [__DynamicallyInvokable]
1019  public static sbyte ToSByte(ushort value)
1020  {
1021  if (value > 127)
1022  {
1023  throw new OverflowException(Environment.GetResourceString("Overflow_SByte"));
1024  }
1025  return (sbyte)value;
1026  }
1027 
1033  [CLSCompliant(false)]
1034  [__DynamicallyInvokable]
1035  public static sbyte ToSByte(int value)
1036  {
1037  if (value < -128 || value > 127)
1038  {
1039  throw new OverflowException(Environment.GetResourceString("Overflow_SByte"));
1040  }
1041  return (sbyte)value;
1042  }
1043 
1049  [CLSCompliant(false)]
1050  [__DynamicallyInvokable]
1051  public static sbyte ToSByte(uint value)
1052  {
1053  if ((long)value > 127L)
1054  {
1055  throw new OverflowException(Environment.GetResourceString("Overflow_SByte"));
1056  }
1057  return (sbyte)value;
1058  }
1059 
1065  [CLSCompliant(false)]
1066  [__DynamicallyInvokable]
1067  public static sbyte ToSByte(long value)
1068  {
1069  if (value < -128 || value > 127)
1070  {
1071  throw new OverflowException(Environment.GetResourceString("Overflow_SByte"));
1072  }
1073  return (sbyte)value;
1074  }
1075 
1081  [CLSCompliant(false)]
1082  [__DynamicallyInvokable]
1083  public static sbyte ToSByte(ulong value)
1084  {
1085  if (value > 127)
1086  {
1087  throw new OverflowException(Environment.GetResourceString("Overflow_SByte"));
1088  }
1089  return (sbyte)value;
1090  }
1091 
1098  [CLSCompliant(false)]
1099  [__DynamicallyInvokable]
1100  public static sbyte ToSByte(float value)
1101  {
1102  return ToSByte((double)value);
1103  }
1104 
1111  [CLSCompliant(false)]
1112  [__DynamicallyInvokable]
1113  public static sbyte ToSByte(double value)
1114  {
1115  return ToSByte(ToInt32(value));
1116  }
1117 
1124  [CLSCompliant(false)]
1125  [__DynamicallyInvokable]
1126  public static sbyte ToSByte(decimal value)
1127  {
1128  return decimal.ToSByte(decimal.Round(value, 0));
1129  }
1130 
1138  [CLSCompliant(false)]
1139  [__DynamicallyInvokable]
1140  public static sbyte ToSByte(string value)
1141  {
1142  if (value == null)
1143  {
1144  return 0;
1145  }
1146  return sbyte.Parse(value, CultureInfo.CurrentCulture);
1147  }
1148 
1159  [CLSCompliant(false)]
1160  [__DynamicallyInvokable]
1161  public static sbyte ToSByte(string value, IFormatProvider provider)
1162  {
1163  return sbyte.Parse(value, NumberStyles.Integer, provider);
1164  }
1165 
1170  [CLSCompliant(false)]
1171  public static sbyte ToSByte(DateTime value)
1172  {
1173  return ((IConvertible)value).ToSByte((IFormatProvider)null);
1174  }
1175 
1185  [__DynamicallyInvokable]
1186  public static byte ToByte(object value)
1187  {
1188  if (value != null)
1189  {
1190  return ((IConvertible)value).ToByte(null);
1191  }
1192  return 0;
1193  }
1194 
1205  [__DynamicallyInvokable]
1206  public static byte ToByte(object value, IFormatProvider provider)
1207  {
1208  if (value != null)
1209  {
1210  return ((IConvertible)value).ToByte(provider);
1211  }
1212  return 0;
1213  }
1214 
1218  [__DynamicallyInvokable]
1219  public static byte ToByte(bool value)
1220  {
1221  if (!value)
1222  {
1223  return 0;
1224  }
1225  return 1;
1226  }
1227 
1232  [__DynamicallyInvokable]
1233  public static byte ToByte(byte value)
1234  {
1235  return value;
1236  }
1237 
1243  [__DynamicallyInvokable]
1244  public static byte ToByte(char value)
1245  {
1246  if (value > 'ÿ')
1247  {
1248  throw new OverflowException(Environment.GetResourceString("Overflow_Byte"));
1249  }
1250  return (byte)value;
1251  }
1252 
1258  [CLSCompliant(false)]
1259  [__DynamicallyInvokable]
1260  public static byte ToByte(sbyte value)
1261  {
1262  if (value < 0)
1263  {
1264  throw new OverflowException(Environment.GetResourceString("Overflow_Byte"));
1265  }
1266  return (byte)value;
1267  }
1268 
1274  [__DynamicallyInvokable]
1275  public static byte ToByte(short value)
1276  {
1277  if (value < 0 || value > 255)
1278  {
1279  throw new OverflowException(Environment.GetResourceString("Overflow_Byte"));
1280  }
1281  return (byte)value;
1282  }
1283 
1289  [CLSCompliant(false)]
1290  [__DynamicallyInvokable]
1291  public static byte ToByte(ushort value)
1292  {
1293  if (value > 255)
1294  {
1295  throw new OverflowException(Environment.GetResourceString("Overflow_Byte"));
1296  }
1297  return (byte)value;
1298  }
1299 
1305  [__DynamicallyInvokable]
1306  public static byte ToByte(int value)
1307  {
1308  if (value < 0 || value > 255)
1309  {
1310  throw new OverflowException(Environment.GetResourceString("Overflow_Byte"));
1311  }
1312  return (byte)value;
1313  }
1314 
1320  [CLSCompliant(false)]
1321  [__DynamicallyInvokable]
1322  public static byte ToByte(uint value)
1323  {
1324  if (value > 255)
1325  {
1326  throw new OverflowException(Environment.GetResourceString("Overflow_Byte"));
1327  }
1328  return (byte)value;
1329  }
1330 
1336  [__DynamicallyInvokable]
1337  public static byte ToByte(long value)
1338  {
1339  if (value < 0 || value > 255)
1340  {
1341  throw new OverflowException(Environment.GetResourceString("Overflow_Byte"));
1342  }
1343  return (byte)value;
1344  }
1345 
1351  [CLSCompliant(false)]
1352  [__DynamicallyInvokable]
1353  public static byte ToByte(ulong value)
1354  {
1355  if (value > 255)
1356  {
1357  throw new OverflowException(Environment.GetResourceString("Overflow_Byte"));
1358  }
1359  return (byte)value;
1360  }
1361 
1368  [__DynamicallyInvokable]
1369  public static byte ToByte(float value)
1370  {
1371  return ToByte((double)value);
1372  }
1373 
1380  [__DynamicallyInvokable]
1381  public static byte ToByte(double value)
1382  {
1383  return ToByte(ToInt32(value));
1384  }
1385 
1392  [__DynamicallyInvokable]
1393  public static byte ToByte(decimal value)
1394  {
1395  return decimal.ToByte(decimal.Round(value, 0));
1396  }
1397 
1405  [__DynamicallyInvokable]
1406  public static byte ToByte(string value)
1407  {
1408  if (value == null)
1409  {
1410  return 0;
1411  }
1412  return byte.Parse(value, CultureInfo.CurrentCulture);
1413  }
1414 
1423  [__DynamicallyInvokable]
1424  public static byte ToByte(string value, IFormatProvider provider)
1425  {
1426  if (value == null)
1427  {
1428  return 0;
1429  }
1430  return byte.Parse(value, NumberStyles.Integer, provider);
1431  }
1432 
1437  public static byte ToByte(DateTime value)
1438  {
1439  return ((IConvertible)value).ToByte((IFormatProvider)null);
1440  }
1441 
1451  [__DynamicallyInvokable]
1452  public static short ToInt16(object value)
1453  {
1454  if (value != null)
1455  {
1456  return ((IConvertible)value).ToInt16(null);
1457  }
1458  return 0;
1459  }
1460 
1471  [__DynamicallyInvokable]
1472  public static short ToInt16(object value, IFormatProvider provider)
1473  {
1474  if (value != null)
1475  {
1476  return ((IConvertible)value).ToInt16(provider);
1477  }
1478  return 0;
1479  }
1480 
1484  [__DynamicallyInvokable]
1485  public static short ToInt16(bool value)
1486  {
1487  if (!value)
1488  {
1489  return 0;
1490  }
1491  return 1;
1492  }
1493 
1499  [__DynamicallyInvokable]
1500  public static short ToInt16(char value)
1501  {
1502  if (value > 'ç¿¿')
1503  {
1504  throw new OverflowException(Environment.GetResourceString("Overflow_Int16"));
1505  }
1506  return (short)value;
1507  }
1508 
1512  [CLSCompliant(false)]
1513  [__DynamicallyInvokable]
1514  public static short ToInt16(sbyte value)
1515  {
1516  return value;
1517  }
1518 
1522  [__DynamicallyInvokable]
1523  public static short ToInt16(byte value)
1524  {
1525  return value;
1526  }
1527 
1533  [CLSCompliant(false)]
1534  [__DynamicallyInvokable]
1535  public static short ToInt16(ushort value)
1536  {
1537  if (value > 32767)
1538  {
1539  throw new OverflowException(Environment.GetResourceString("Overflow_Int16"));
1540  }
1541  return (short)value;
1542  }
1543 
1549  [__DynamicallyInvokable]
1550  public static short ToInt16(int value)
1551  {
1552  if (value < -32768 || value > 32767)
1553  {
1554  throw new OverflowException(Environment.GetResourceString("Overflow_Int16"));
1555  }
1556  return (short)value;
1557  }
1558 
1564  [CLSCompliant(false)]
1565  [__DynamicallyInvokable]
1566  public static short ToInt16(uint value)
1567  {
1568  if ((long)value > 32767L)
1569  {
1570  throw new OverflowException(Environment.GetResourceString("Overflow_Int16"));
1571  }
1572  return (short)value;
1573  }
1574 
1579  [__DynamicallyInvokable]
1580  public static short ToInt16(short value)
1581  {
1582  return value;
1583  }
1584 
1590  [__DynamicallyInvokable]
1591  public static short ToInt16(long value)
1592  {
1593  if (value < -32768 || value > 32767)
1594  {
1595  throw new OverflowException(Environment.GetResourceString("Overflow_Int16"));
1596  }
1597  return (short)value;
1598  }
1599 
1605  [CLSCompliant(false)]
1606  [__DynamicallyInvokable]
1607  public static short ToInt16(ulong value)
1608  {
1609  if (value > 32767)
1610  {
1611  throw new OverflowException(Environment.GetResourceString("Overflow_Int16"));
1612  }
1613  return (short)value;
1614  }
1615 
1622  [__DynamicallyInvokable]
1623  public static short ToInt16(float value)
1624  {
1625  return ToInt16((double)value);
1626  }
1627 
1634  [__DynamicallyInvokable]
1635  public static short ToInt16(double value)
1636  {
1637  return ToInt16(ToInt32(value));
1638  }
1639 
1646  [__DynamicallyInvokable]
1647  public static short ToInt16(decimal value)
1648  {
1649  return decimal.ToInt16(decimal.Round(value, 0));
1650  }
1651 
1659  [__DynamicallyInvokable]
1660  public static short ToInt16(string value)
1661  {
1662  if (value == null)
1663  {
1664  return 0;
1665  }
1666  return short.Parse(value, CultureInfo.CurrentCulture);
1667  }
1668 
1677  [__DynamicallyInvokable]
1678  public static short ToInt16(string value, IFormatProvider provider)
1679  {
1680  if (value == null)
1681  {
1682  return 0;
1683  }
1684  return short.Parse(value, NumberStyles.Integer, provider);
1685  }
1686 
1691  public static short ToInt16(DateTime value)
1692  {
1693  return ((IConvertible)value).ToInt16((IFormatProvider)null);
1694  }
1695 
1705  [CLSCompliant(false)]
1706  [__DynamicallyInvokable]
1707  public static ushort ToUInt16(object value)
1708  {
1709  if (value != null)
1710  {
1711  return ((IConvertible)value).ToUInt16(null);
1712  }
1713  return 0;
1714  }
1715 
1726  [CLSCompliant(false)]
1727  [__DynamicallyInvokable]
1728  public static ushort ToUInt16(object value, IFormatProvider provider)
1729  {
1730  if (value != null)
1731  {
1732  return ((IConvertible)value).ToUInt16(provider);
1733  }
1734  return 0;
1735  }
1736 
1740  [CLSCompliant(false)]
1741  [__DynamicallyInvokable]
1742  public static ushort ToUInt16(bool value)
1743  {
1744  if (!value)
1745  {
1746  return 0;
1747  }
1748  return 1;
1749  }
1750 
1754  [CLSCompliant(false)]
1755  [__DynamicallyInvokable]
1756  public static ushort ToUInt16(char value)
1757  {
1758  return value;
1759  }
1760 
1766  [CLSCompliant(false)]
1767  [__DynamicallyInvokable]
1768  public static ushort ToUInt16(sbyte value)
1769  {
1770  if (value < 0)
1771  {
1772  throw new OverflowException(Environment.GetResourceString("Overflow_UInt16"));
1773  }
1774  return (ushort)value;
1775  }
1776 
1780  [CLSCompliant(false)]
1781  [__DynamicallyInvokable]
1782  public static ushort ToUInt16(byte value)
1783  {
1784  return value;
1785  }
1786 
1792  [CLSCompliant(false)]
1793  [__DynamicallyInvokable]
1794  public static ushort ToUInt16(short value)
1795  {
1796  if (value < 0)
1797  {
1798  throw new OverflowException(Environment.GetResourceString("Overflow_UInt16"));
1799  }
1800  return (ushort)value;
1801  }
1802 
1808  [CLSCompliant(false)]
1809  [__DynamicallyInvokable]
1810  public static ushort ToUInt16(int value)
1811  {
1812  if (value < 0 || value > 65535)
1813  {
1814  throw new OverflowException(Environment.GetResourceString("Overflow_UInt16"));
1815  }
1816  return (ushort)value;
1817  }
1818 
1823  [CLSCompliant(false)]
1824  [__DynamicallyInvokable]
1825  public static ushort ToUInt16(ushort value)
1826  {
1827  return value;
1828  }
1829 
1835  [CLSCompliant(false)]
1836  [__DynamicallyInvokable]
1837  public static ushort ToUInt16(uint value)
1838  {
1839  if (value > 65535)
1840  {
1841  throw new OverflowException(Environment.GetResourceString("Overflow_UInt16"));
1842  }
1843  return (ushort)value;
1844  }
1845 
1851  [CLSCompliant(false)]
1852  [__DynamicallyInvokable]
1853  public static ushort ToUInt16(long value)
1854  {
1855  if (value < 0 || value > 65535)
1856  {
1857  throw new OverflowException(Environment.GetResourceString("Overflow_UInt16"));
1858  }
1859  return (ushort)value;
1860  }
1861 
1867  [CLSCompliant(false)]
1868  [__DynamicallyInvokable]
1869  public static ushort ToUInt16(ulong value)
1870  {
1871  if (value > 65535)
1872  {
1873  throw new OverflowException(Environment.GetResourceString("Overflow_UInt16"));
1874  }
1875  return (ushort)value;
1876  }
1877 
1884  [CLSCompliant(false)]
1885  [__DynamicallyInvokable]
1886  public static ushort ToUInt16(float value)
1887  {
1888  return ToUInt16((double)value);
1889  }
1890 
1897  [CLSCompliant(false)]
1898  [__DynamicallyInvokable]
1899  public static ushort ToUInt16(double value)
1900  {
1901  return ToUInt16(ToInt32(value));
1902  }
1903 
1910  [CLSCompliant(false)]
1911  [__DynamicallyInvokable]
1912  public static ushort ToUInt16(decimal value)
1913  {
1914  return decimal.ToUInt16(decimal.Round(value, 0));
1915  }
1916 
1924  [CLSCompliant(false)]
1925  [__DynamicallyInvokable]
1926  public static ushort ToUInt16(string value)
1927  {
1928  if (value == null)
1929  {
1930  return 0;
1931  }
1932  return ushort.Parse(value, CultureInfo.CurrentCulture);
1933  }
1934 
1943  [CLSCompliant(false)]
1944  [__DynamicallyInvokable]
1945  public static ushort ToUInt16(string value, IFormatProvider provider)
1946  {
1947  if (value == null)
1948  {
1949  return 0;
1950  }
1951  return ushort.Parse(value, NumberStyles.Integer, provider);
1952  }
1953 
1958  [CLSCompliant(false)]
1959  public static ushort ToUInt16(DateTime value)
1960  {
1961  return ((IConvertible)value).ToUInt16((IFormatProvider)null);
1962  }
1963 
1973  [__DynamicallyInvokable]
1974  public static int ToInt32(object value)
1975  {
1976  if (value != null)
1977  {
1978  return ((IConvertible)value).ToInt32(null);
1979  }
1980  return 0;
1981  }
1982 
1993  [__DynamicallyInvokable]
1994  public static int ToInt32(object value, IFormatProvider provider)
1995  {
1996  if (value != null)
1997  {
1998  return ((IConvertible)value).ToInt32(provider);
1999  }
2000  return 0;
2001  }
2002 
2006  [__DynamicallyInvokable]
2007  public static int ToInt32(bool value)
2008  {
2009  if (!value)
2010  {
2011  return 0;
2012  }
2013  return 1;
2014  }
2015 
2019  [__DynamicallyInvokable]
2020  public static int ToInt32(char value)
2021  {
2022  return value;
2023  }
2024 
2028  [CLSCompliant(false)]
2029  [__DynamicallyInvokable]
2030  public static int ToInt32(sbyte value)
2031  {
2032  return value;
2033  }
2034 
2038  [__DynamicallyInvokable]
2039  public static int ToInt32(byte value)
2040  {
2041  return value;
2042  }
2043 
2047  [__DynamicallyInvokable]
2048  public static int ToInt32(short value)
2049  {
2050  return value;
2051  }
2052 
2056  [CLSCompliant(false)]
2057  [__DynamicallyInvokable]
2058  public static int ToInt32(ushort value)
2059  {
2060  return value;
2061  }
2062 
2068  [CLSCompliant(false)]
2069  [__DynamicallyInvokable]
2070  public static int ToInt32(uint value)
2071  {
2072  if (value > int.MaxValue)
2073  {
2074  throw new OverflowException(Environment.GetResourceString("Overflow_Int32"));
2075  }
2076  return (int)value;
2077  }
2078 
2083  [__DynamicallyInvokable]
2084  public static int ToInt32(int value)
2085  {
2086  return value;
2087  }
2088 
2094  [__DynamicallyInvokable]
2095  public static int ToInt32(long value)
2096  {
2097  if (value < int.MinValue || value > int.MaxValue)
2098  {
2099  throw new OverflowException(Environment.GetResourceString("Overflow_Int32"));
2100  }
2101  return (int)value;
2102  }
2103 
2109  [CLSCompliant(false)]
2110  [__DynamicallyInvokable]
2111  public static int ToInt32(ulong value)
2112  {
2113  if (value > int.MaxValue)
2114  {
2115  throw new OverflowException(Environment.GetResourceString("Overflow_Int32"));
2116  }
2117  return (int)value;
2118  }
2119 
2126  [__DynamicallyInvokable]
2127  public static int ToInt32(float value)
2128  {
2129  return ToInt32((double)value);
2130  }
2131 
2138  [__DynamicallyInvokable]
2139  public static int ToInt32(double value)
2140  {
2141  if (value >= 0.0)
2142  {
2143  if (value < 2147483647.5)
2144  {
2145  int num = (int)value;
2146  double num2 = value - (double)num;
2147  if (num2 > 0.5 || (num2 == 0.5 && (num & 1) != 0))
2148  {
2149  num++;
2150  }
2151  return num;
2152  }
2153  }
2154  else if (value >= -2147483648.5)
2155  {
2156  int num3 = (int)value;
2157  double num4 = value - (double)num3;
2158  if (num4 < -0.5 || (num4 == -0.5 && (num3 & 1) != 0))
2159  {
2160  num3--;
2161  }
2162  return num3;
2163  }
2164  throw new OverflowException(Environment.GetResourceString("Overflow_Int32"));
2165  }
2166 
2173  [SecuritySafeCritical]
2174  [__DynamicallyInvokable]
2175  public static int ToInt32(decimal value)
2176  {
2177  return decimal.FCallToInt32(value);
2178  }
2179 
2187  [__DynamicallyInvokable]
2188  public static int ToInt32(string value)
2189  {
2190  if (value == null)
2191  {
2192  return 0;
2193  }
2194  return int.Parse(value, CultureInfo.CurrentCulture);
2195  }
2196 
2205  [__DynamicallyInvokable]
2206  public static int ToInt32(string value, IFormatProvider provider)
2207  {
2208  if (value == null)
2209  {
2210  return 0;
2211  }
2212  return int.Parse(value, NumberStyles.Integer, provider);
2213  }
2214 
2219  public static int ToInt32(DateTime value)
2220  {
2221  return ((IConvertible)value).ToInt32((IFormatProvider)null);
2222  }
2223 
2233  [CLSCompliant(false)]
2234  [__DynamicallyInvokable]
2235  public static uint ToUInt32(object value)
2236  {
2237  if (value != null)
2238  {
2239  return ((IConvertible)value).ToUInt32(null);
2240  }
2241  return 0u;
2242  }
2243 
2254  [CLSCompliant(false)]
2255  [__DynamicallyInvokable]
2256  public static uint ToUInt32(object value, IFormatProvider provider)
2257  {
2258  if (value != null)
2259  {
2260  return ((IConvertible)value).ToUInt32(provider);
2261  }
2262  return 0u;
2263  }
2264 
2268  [CLSCompliant(false)]
2269  [__DynamicallyInvokable]
2270  public static uint ToUInt32(bool value)
2271  {
2272  if (!value)
2273  {
2274  return 0u;
2275  }
2276  return 1u;
2277  }
2278 
2282  [CLSCompliant(false)]
2283  [__DynamicallyInvokable]
2284  public static uint ToUInt32(char value)
2285  {
2286  return value;
2287  }
2288 
2294  [CLSCompliant(false)]
2295  [__DynamicallyInvokable]
2296  public static uint ToUInt32(sbyte value)
2297  {
2298  if (value < 0)
2299  {
2300  throw new OverflowException(Environment.GetResourceString("Overflow_UInt32"));
2301  }
2302  return (uint)value;
2303  }
2304 
2308  [CLSCompliant(false)]
2309  [__DynamicallyInvokable]
2310  public static uint ToUInt32(byte value)
2311  {
2312  return value;
2313  }
2314 
2320  [CLSCompliant(false)]
2321  [__DynamicallyInvokable]
2322  public static uint ToUInt32(short value)
2323  {
2324  if (value < 0)
2325  {
2326  throw new OverflowException(Environment.GetResourceString("Overflow_UInt32"));
2327  }
2328  return (uint)value;
2329  }
2330 
2334  [CLSCompliant(false)]
2335  [__DynamicallyInvokable]
2336  public static uint ToUInt32(ushort value)
2337  {
2338  return value;
2339  }
2340 
2346  [CLSCompliant(false)]
2347  [__DynamicallyInvokable]
2348  public static uint ToUInt32(int value)
2349  {
2350  if (value < 0)
2351  {
2352  throw new OverflowException(Environment.GetResourceString("Overflow_UInt32"));
2353  }
2354  return (uint)value;
2355  }
2356 
2361  [CLSCompliant(false)]
2362  [__DynamicallyInvokable]
2363  public static uint ToUInt32(uint value)
2364  {
2365  return value;
2366  }
2367 
2373  [CLSCompliant(false)]
2374  [__DynamicallyInvokable]
2375  public static uint ToUInt32(long value)
2376  {
2377  if (value < 0 || value > uint.MaxValue)
2378  {
2379  throw new OverflowException(Environment.GetResourceString("Overflow_UInt32"));
2380  }
2381  return (uint)value;
2382  }
2383 
2389  [CLSCompliant(false)]
2390  [__DynamicallyInvokable]
2391  public static uint ToUInt32(ulong value)
2392  {
2393  if (value > uint.MaxValue)
2394  {
2395  throw new OverflowException(Environment.GetResourceString("Overflow_UInt32"));
2396  }
2397  return (uint)value;
2398  }
2399 
2406  [CLSCompliant(false)]
2407  [__DynamicallyInvokable]
2408  public static uint ToUInt32(float value)
2409  {
2410  return ToUInt32((double)value);
2411  }
2412 
2419  [CLSCompliant(false)]
2420  [__DynamicallyInvokable]
2421  public static uint ToUInt32(double value)
2422  {
2423  if (value >= -0.5 && value < 4294967295.5)
2424  {
2425  uint num = (uint)value;
2426  double num2 = value - (double)num;
2427  if (num2 > 0.5 || (num2 == 0.5 && (num & 1) != 0))
2428  {
2429  num++;
2430  }
2431  return num;
2432  }
2433  throw new OverflowException(Environment.GetResourceString("Overflow_UInt32"));
2434  }
2435 
2442  [CLSCompliant(false)]
2443  [__DynamicallyInvokable]
2444  public static uint ToUInt32(decimal value)
2445  {
2446  return decimal.ToUInt32(decimal.Round(value, 0));
2447  }
2448 
2456  [CLSCompliant(false)]
2457  [__DynamicallyInvokable]
2458  public static uint ToUInt32(string value)
2459  {
2460  if (value == null)
2461  {
2462  return 0u;
2463  }
2464  return uint.Parse(value, CultureInfo.CurrentCulture);
2465  }
2466 
2475  [CLSCompliant(false)]
2476  [__DynamicallyInvokable]
2477  public static uint ToUInt32(string value, IFormatProvider provider)
2478  {
2479  if (value == null)
2480  {
2481  return 0u;
2482  }
2483  return uint.Parse(value, NumberStyles.Integer, provider);
2484  }
2485 
2490  [CLSCompliant(false)]
2491  public static uint ToUInt32(DateTime value)
2492  {
2493  return ((IConvertible)value).ToUInt32((IFormatProvider)null);
2494  }
2495 
2505  [__DynamicallyInvokable]
2506  public static long ToInt64(object value)
2507  {
2508  if (value != null)
2509  {
2510  return ((IConvertible)value).ToInt64(null);
2511  }
2512  return 0L;
2513  }
2514 
2525  [__DynamicallyInvokable]
2526  public static long ToInt64(object value, IFormatProvider provider)
2527  {
2528  if (value != null)
2529  {
2530  return ((IConvertible)value).ToInt64(provider);
2531  }
2532  return 0L;
2533  }
2534 
2538  [__DynamicallyInvokable]
2539  public static long ToInt64(bool value)
2540  {
2541  return value ? 1 : 0;
2542  }
2543 
2547  [__DynamicallyInvokable]
2548  public static long ToInt64(char value)
2549  {
2550  return value;
2551  }
2552 
2556  [CLSCompliant(false)]
2557  [__DynamicallyInvokable]
2558  public static long ToInt64(sbyte value)
2559  {
2560  return value;
2561  }
2562 
2566  [__DynamicallyInvokable]
2567  public static long ToInt64(byte value)
2568  {
2569  return value;
2570  }
2571 
2575  [__DynamicallyInvokable]
2576  public static long ToInt64(short value)
2577  {
2578  return value;
2579  }
2580 
2584  [CLSCompliant(false)]
2585  [__DynamicallyInvokable]
2586  public static long ToInt64(ushort value)
2587  {
2588  return value;
2589  }
2590 
2594  [__DynamicallyInvokable]
2595  public static long ToInt64(int value)
2596  {
2597  return value;
2598  }
2599 
2603  [CLSCompliant(false)]
2604  [__DynamicallyInvokable]
2605  public static long ToInt64(uint value)
2606  {
2607  return value;
2608  }
2609 
2615  [CLSCompliant(false)]
2616  [__DynamicallyInvokable]
2617  public static long ToInt64(ulong value)
2618  {
2619  if (value > long.MaxValue)
2620  {
2621  throw new OverflowException(Environment.GetResourceString("Overflow_Int64"));
2622  }
2623  return (long)value;
2624  }
2625 
2630  [__DynamicallyInvokable]
2631  public static long ToInt64(long value)
2632  {
2633  return value;
2634  }
2635 
2642  [__DynamicallyInvokable]
2643  public static long ToInt64(float value)
2644  {
2645  return ToInt64((double)value);
2646  }
2647 
2654  [__DynamicallyInvokable]
2655  public static long ToInt64(double value)
2656  {
2657  return checked((long)Math.Round(value));
2658  }
2659 
2666  [__DynamicallyInvokable]
2667  public static long ToInt64(decimal value)
2668  {
2669  return decimal.ToInt64(decimal.Round(value, 0));
2670  }
2671 
2679  [__DynamicallyInvokable]
2680  public static long ToInt64(string value)
2681  {
2682  if (value == null)
2683  {
2684  return 0L;
2685  }
2686  return long.Parse(value, CultureInfo.CurrentCulture);
2687  }
2688 
2697  [__DynamicallyInvokable]
2698  public static long ToInt64(string value, IFormatProvider provider)
2699  {
2700  if (value == null)
2701  {
2702  return 0L;
2703  }
2704  return long.Parse(value, NumberStyles.Integer, provider);
2705  }
2706 
2711  public static long ToInt64(DateTime value)
2712  {
2713  return ((IConvertible)value).ToInt64((IFormatProvider)null);
2714  }
2715 
2725  [CLSCompliant(false)]
2726  [__DynamicallyInvokable]
2727  public static ulong ToUInt64(object value)
2728  {
2729  if (value != null)
2730  {
2731  return ((IConvertible)value).ToUInt64(null);
2732  }
2733  return 0uL;
2734  }
2735 
2746  [CLSCompliant(false)]
2747  [__DynamicallyInvokable]
2748  public static ulong ToUInt64(object value, IFormatProvider provider)
2749  {
2750  if (value != null)
2751  {
2752  return ((IConvertible)value).ToUInt64(provider);
2753  }
2754  return 0uL;
2755  }
2756 
2760  [CLSCompliant(false)]
2761  [__DynamicallyInvokable]
2762  public static ulong ToUInt64(bool value)
2763  {
2764  if (!value)
2765  {
2766  return 0uL;
2767  }
2768  return 1uL;
2769  }
2770 
2774  [CLSCompliant(false)]
2775  [__DynamicallyInvokable]
2776  public static ulong ToUInt64(char value)
2777  {
2778  return value;
2779  }
2780 
2786  [CLSCompliant(false)]
2787  [__DynamicallyInvokable]
2788  public static ulong ToUInt64(sbyte value)
2789  {
2790  if (value < 0)
2791  {
2792  throw new OverflowException(Environment.GetResourceString("Overflow_UInt64"));
2793  }
2794  return (ulong)value;
2795  }
2796 
2800  [CLSCompliant(false)]
2801  [__DynamicallyInvokable]
2802  public static ulong ToUInt64(byte value)
2803  {
2804  return value;
2805  }
2806 
2812  [CLSCompliant(false)]
2813  [__DynamicallyInvokable]
2814  public static ulong ToUInt64(short value)
2815  {
2816  if (value < 0)
2817  {
2818  throw new OverflowException(Environment.GetResourceString("Overflow_UInt64"));
2819  }
2820  return (ulong)value;
2821  }
2822 
2826  [CLSCompliant(false)]
2827  [__DynamicallyInvokable]
2828  public static ulong ToUInt64(ushort value)
2829  {
2830  return value;
2831  }
2832 
2838  [CLSCompliant(false)]
2839  [__DynamicallyInvokable]
2840  public static ulong ToUInt64(int value)
2841  {
2842  if (value < 0)
2843  {
2844  throw new OverflowException(Environment.GetResourceString("Overflow_UInt64"));
2845  }
2846  return (ulong)value;
2847  }
2848 
2852  [CLSCompliant(false)]
2853  [__DynamicallyInvokable]
2854  public static ulong ToUInt64(uint value)
2855  {
2856  return value;
2857  }
2858 
2864  [CLSCompliant(false)]
2865  [__DynamicallyInvokable]
2866  public static ulong ToUInt64(long value)
2867  {
2868  if (value < 0)
2869  {
2870  throw new OverflowException(Environment.GetResourceString("Overflow_UInt64"));
2871  }
2872  return (ulong)value;
2873  }
2874 
2879  [CLSCompliant(false)]
2880  [__DynamicallyInvokable]
2881  public static ulong ToUInt64(ulong value)
2882  {
2883  return value;
2884  }
2885 
2892  [CLSCompliant(false)]
2893  [__DynamicallyInvokable]
2894  public static ulong ToUInt64(float value)
2895  {
2896  return ToUInt64((double)value);
2897  }
2898 
2905  [CLSCompliant(false)]
2906  [__DynamicallyInvokable]
2907  public static ulong ToUInt64(double value)
2908  {
2909  return checked((ulong)Math.Round(value));
2910  }
2911 
2918  [CLSCompliant(false)]
2919  [__DynamicallyInvokable]
2920  public static ulong ToUInt64(decimal value)
2921  {
2922  return decimal.ToUInt64(decimal.Round(value, 0));
2923  }
2924 
2932  [CLSCompliant(false)]
2933  [__DynamicallyInvokable]
2934  public static ulong ToUInt64(string value)
2935  {
2936  if (value == null)
2937  {
2938  return 0uL;
2939  }
2940  return ulong.Parse(value, CultureInfo.CurrentCulture);
2941  }
2942 
2951  [CLSCompliant(false)]
2952  [__DynamicallyInvokable]
2953  public static ulong ToUInt64(string value, IFormatProvider provider)
2954  {
2955  if (value == null)
2956  {
2957  return 0uL;
2958  }
2959  return ulong.Parse(value, NumberStyles.Integer, provider);
2960  }
2961 
2966  [CLSCompliant(false)]
2967  public static ulong ToUInt64(DateTime value)
2968  {
2969  return ((IConvertible)value).ToUInt64((IFormatProvider)null);
2970  }
2971 
2981  [__DynamicallyInvokable]
2982  public static float ToSingle(object value)
2983  {
2984  if (value != null)
2985  {
2986  return ((IConvertible)value).ToSingle(null);
2987  }
2988  return 0f;
2989  }
2990 
3001  [__DynamicallyInvokable]
3002  public static float ToSingle(object value, IFormatProvider provider)
3003  {
3004  if (value != null)
3005  {
3006  return ((IConvertible)value).ToSingle(provider);
3007  }
3008  return 0f;
3009  }
3010 
3014  [CLSCompliant(false)]
3015  [__DynamicallyInvokable]
3016  public static float ToSingle(sbyte value)
3017  {
3018  return value;
3019  }
3020 
3024  [__DynamicallyInvokable]
3025  public static float ToSingle(byte value)
3026  {
3027  return (int)value;
3028  }
3029 
3034  public static float ToSingle(char value)
3035  {
3036  return ((IConvertible)value).ToSingle((IFormatProvider)null);
3037  }
3038 
3042  [__DynamicallyInvokable]
3043  public static float ToSingle(short value)
3044  {
3045  return value;
3046  }
3047 
3051  [CLSCompliant(false)]
3052  [__DynamicallyInvokable]
3053  public static float ToSingle(ushort value)
3054  {
3055  return (int)value;
3056  }
3057 
3061  [__DynamicallyInvokable]
3062  public static float ToSingle(int value)
3063  {
3064  return value;
3065  }
3066 
3070  [CLSCompliant(false)]
3071  [__DynamicallyInvokable]
3072  public static float ToSingle(uint value)
3073  {
3074  return (float)(double)value;
3075  }
3076 
3080  [__DynamicallyInvokable]
3081  public static float ToSingle(long value)
3082  {
3083  return value;
3084  }
3085 
3089  [CLSCompliant(false)]
3090  [__DynamicallyInvokable]
3091  public static float ToSingle(ulong value)
3092  {
3093  return (float)(double)value;
3094  }
3095 
3100  [__DynamicallyInvokable]
3101  public static float ToSingle(float value)
3102  {
3103  return value;
3104  }
3105 
3110  [__DynamicallyInvokable]
3111  public static float ToSingle(double value)
3112  {
3113  return (float)value;
3114  }
3115 
3120  [__DynamicallyInvokable]
3121  public static float ToSingle(decimal value)
3122  {
3123  return (float)value;
3124  }
3125 
3133  [__DynamicallyInvokable]
3134  public static float ToSingle(string value)
3135  {
3136  if (value == null)
3137  {
3138  return 0f;
3139  }
3140  return float.Parse(value, CultureInfo.CurrentCulture);
3141  }
3142 
3151  [__DynamicallyInvokable]
3152  public static float ToSingle(string value, IFormatProvider provider)
3153  {
3154  if (value == null)
3155  {
3156  return 0f;
3157  }
3158  return float.Parse(value, NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.AllowLeadingSign | NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands | NumberStyles.AllowExponent, provider);
3159  }
3160 
3164  [__DynamicallyInvokable]
3165  public static float ToSingle(bool value)
3166  {
3167  return value ? 1 : 0;
3168  }
3169 
3174  public static float ToSingle(DateTime value)
3175  {
3176  return ((IConvertible)value).ToSingle((IFormatProvider)null);
3177  }
3178 
3188  [__DynamicallyInvokable]
3189  public static double ToDouble(object value)
3190  {
3191  if (value != null)
3192  {
3193  return ((IConvertible)value).ToDouble(null);
3194  }
3195  return 0.0;
3196  }
3197 
3208  [__DynamicallyInvokable]
3209  public static double ToDouble(object value, IFormatProvider provider)
3210  {
3211  if (value != null)
3212  {
3213  return ((IConvertible)value).ToDouble(provider);
3214  }
3215  return 0.0;
3216  }
3217 
3221  [CLSCompliant(false)]
3222  [__DynamicallyInvokable]
3223  public static double ToDouble(sbyte value)
3224  {
3225  return value;
3226  }
3227 
3231  [__DynamicallyInvokable]
3232  public static double ToDouble(byte value)
3233  {
3234  return (int)value;
3235  }
3236 
3240  [__DynamicallyInvokable]
3241  public static double ToDouble(short value)
3242  {
3243  return value;
3244  }
3245 
3250  public static double ToDouble(char value)
3251  {
3252  return ((IConvertible)value).ToDouble((IFormatProvider)null);
3253  }
3254 
3258  [CLSCompliant(false)]
3259  [__DynamicallyInvokable]
3260  public static double ToDouble(ushort value)
3261  {
3262  return (int)value;
3263  }
3264 
3268  [__DynamicallyInvokable]
3269  public static double ToDouble(int value)
3270  {
3271  return value;
3272  }
3273 
3277  [CLSCompliant(false)]
3278  [__DynamicallyInvokable]
3279  public static double ToDouble(uint value)
3280  {
3281  return value;
3282  }
3283 
3287  [__DynamicallyInvokable]
3288  public static double ToDouble(long value)
3289  {
3290  return value;
3291  }
3292 
3296  [CLSCompliant(false)]
3297  [__DynamicallyInvokable]
3298  public static double ToDouble(ulong value)
3299  {
3300  return value;
3301  }
3302 
3306  [__DynamicallyInvokable]
3307  public static double ToDouble(float value)
3308  {
3309  return value;
3310  }
3311 
3316  [__DynamicallyInvokable]
3317  public static double ToDouble(double value)
3318  {
3319  return value;
3320  }
3321 
3325  [__DynamicallyInvokable]
3326  public static double ToDouble(decimal value)
3327  {
3328  return (double)value;
3329  }
3330 
3338  [__DynamicallyInvokable]
3339  public static double ToDouble(string value)
3340  {
3341  if (value == null)
3342  {
3343  return 0.0;
3344  }
3345  return double.Parse(value, CultureInfo.CurrentCulture);
3346  }
3347 
3356  [__DynamicallyInvokable]
3357  public static double ToDouble(string value, IFormatProvider provider)
3358  {
3359  if (value == null)
3360  {
3361  return 0.0;
3362  }
3363  return double.Parse(value, NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.AllowLeadingSign | NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands | NumberStyles.AllowExponent, provider);
3364  }
3365 
3369  [__DynamicallyInvokable]
3370  public static double ToDouble(bool value)
3371  {
3372  return value ? 1 : 0;
3373  }
3374 
3379  public static double ToDouble(DateTime value)
3380  {
3381  return ((IConvertible)value).ToDouble((IFormatProvider)null);
3382  }
3383 
3393  [__DynamicallyInvokable]
3394  public static decimal ToDecimal(object value)
3395  {
3396  if (value != null)
3397  {
3398  return ((IConvertible)value).ToDecimal(null);
3399  }
3400  return decimal.Zero;
3401  }
3402 
3413  [__DynamicallyInvokable]
3414  public static decimal ToDecimal(object value, IFormatProvider provider)
3415  {
3416  if (value != null)
3417  {
3418  return ((IConvertible)value).ToDecimal(provider);
3419  }
3420  return decimal.Zero;
3421  }
3422 
3426  [CLSCompliant(false)]
3427  [__DynamicallyInvokable]
3428  public static decimal ToDecimal(sbyte value)
3429  {
3430  return value;
3431  }
3432 
3436  [__DynamicallyInvokable]
3437  public static decimal ToDecimal(byte value)
3438  {
3439  return value;
3440  }
3441 
3446  public static decimal ToDecimal(char value)
3447  {
3448  return ((IConvertible)value).ToDecimal((IFormatProvider)null);
3449  }
3450 
3454  [__DynamicallyInvokable]
3455  public static decimal ToDecimal(short value)
3456  {
3457  return value;
3458  }
3459 
3463  [CLSCompliant(false)]
3464  [__DynamicallyInvokable]
3465  public static decimal ToDecimal(ushort value)
3466  {
3467  return value;
3468  }
3469 
3473  [__DynamicallyInvokable]
3474  public static decimal ToDecimal(int value)
3475  {
3476  return value;
3477  }
3478 
3482  [CLSCompliant(false)]
3483  [__DynamicallyInvokable]
3484  public static decimal ToDecimal(uint value)
3485  {
3486  return value;
3487  }
3488 
3492  [__DynamicallyInvokable]
3493  public static decimal ToDecimal(long value)
3494  {
3495  return value;
3496  }
3497 
3501  [CLSCompliant(false)]
3502  [__DynamicallyInvokable]
3503  public static decimal ToDecimal(ulong value)
3504  {
3505  return value;
3506  }
3507 
3513  [__DynamicallyInvokable]
3514  public static decimal ToDecimal(float value)
3515  {
3516  return (decimal)value;
3517  }
3518 
3524  [__DynamicallyInvokable]
3525  public static decimal ToDecimal(double value)
3526  {
3527  return (decimal)value;
3528  }
3529 
3537  [__DynamicallyInvokable]
3538  public static decimal ToDecimal(string value)
3539  {
3540  if (value == null)
3541  {
3542  return decimal.Zero;
3543  }
3544  return decimal.Parse(value, CultureInfo.CurrentCulture);
3545  }
3546 
3555  [__DynamicallyInvokable]
3556  public static decimal ToDecimal(string value, IFormatProvider provider)
3557  {
3558  if (value == null)
3559  {
3560  return decimal.Zero;
3561  }
3562  return decimal.Parse(value, NumberStyles.Number, provider);
3563  }
3564 
3569  [__DynamicallyInvokable]
3570  public static decimal ToDecimal(decimal value)
3571  {
3572  return value;
3573  }
3574 
3578  [__DynamicallyInvokable]
3579  public static decimal ToDecimal(bool value)
3580  {
3581  return value ? 1 : 0;
3582  }
3583 
3588  public static decimal ToDecimal(DateTime value)
3589  {
3590  return ((IConvertible)value).ToDecimal((IFormatProvider)null);
3591  }
3592 
3597  public static DateTime ToDateTime(DateTime value)
3598  {
3599  return value;
3600  }
3601 
3609  [__DynamicallyInvokable]
3610  public static DateTime ToDateTime(object value)
3611  {
3612  if (value != null)
3613  {
3614  return ((IConvertible)value).ToDateTime(null);
3615  }
3616  return DateTime.MinValue;
3617  }
3618 
3627  [__DynamicallyInvokable]
3628  public static DateTime ToDateTime(object value, IFormatProvider provider)
3629  {
3630  if (value != null)
3631  {
3632  return ((IConvertible)value).ToDateTime(provider);
3633  }
3634  return DateTime.MinValue;
3635  }
3636 
3642  [__DynamicallyInvokable]
3643  public static DateTime ToDateTime(string value)
3644  {
3645  if (value == null)
3646  {
3647  return new DateTime(0L);
3648  }
3649  return DateTime.Parse(value, CultureInfo.CurrentCulture);
3650  }
3651 
3658  [__DynamicallyInvokable]
3659  public static DateTime ToDateTime(string value, IFormatProvider provider)
3660  {
3661  if (value == null)
3662  {
3663  return new DateTime(0L);
3664  }
3665  return DateTime.Parse(value, provider);
3666  }
3667 
3672  [CLSCompliant(false)]
3673  public static DateTime ToDateTime(sbyte value)
3674  {
3675  return ((IConvertible)value).ToDateTime((IFormatProvider)null);
3676  }
3677 
3682  public static DateTime ToDateTime(byte value)
3683  {
3684  return ((IConvertible)value).ToDateTime((IFormatProvider)null);
3685  }
3686 
3691  public static DateTime ToDateTime(short value)
3692  {
3693  return ((IConvertible)value).ToDateTime((IFormatProvider)null);
3694  }
3695 
3700  [CLSCompliant(false)]
3701  public static DateTime ToDateTime(ushort value)
3702  {
3703  return ((IConvertible)value).ToDateTime((IFormatProvider)null);
3704  }
3705 
3710  public static DateTime ToDateTime(int value)
3711  {
3712  return ((IConvertible)value).ToDateTime((IFormatProvider)null);
3713  }
3714 
3719  [CLSCompliant(false)]
3720  public static DateTime ToDateTime(uint value)
3721  {
3722  return ((IConvertible)value).ToDateTime((IFormatProvider)null);
3723  }
3724 
3729  public static DateTime ToDateTime(long value)
3730  {
3731  return ((IConvertible)value).ToDateTime((IFormatProvider)null);
3732  }
3733 
3738  [CLSCompliant(false)]
3739  public static DateTime ToDateTime(ulong value)
3740  {
3741  return ((IConvertible)value).ToDateTime((IFormatProvider)null);
3742  }
3743 
3748  public static DateTime ToDateTime(bool value)
3749  {
3750  return ((IConvertible)value).ToDateTime((IFormatProvider)null);
3751  }
3752 
3757  public static DateTime ToDateTime(char value)
3758  {
3759  return ((IConvertible)value).ToDateTime((IFormatProvider)null);
3760  }
3761 
3766  public static DateTime ToDateTime(float value)
3767  {
3768  return ((IConvertible)value).ToDateTime((IFormatProvider)null);
3769  }
3770 
3775  public static DateTime ToDateTime(double value)
3776  {
3777  return ((IConvertible)value).ToDateTime((IFormatProvider)null);
3778  }
3779 
3784  public static DateTime ToDateTime(decimal value)
3785  {
3786  return ((IConvertible)value).ToDateTime((IFormatProvider)null);
3787  }
3788 
3792  [__DynamicallyInvokable]
3793  public static string ToString(object value)
3794  {
3795  return ToString(value, null);
3796  }
3797 
3802  [__DynamicallyInvokable]
3803  public static string ToString(object value, IFormatProvider provider)
3804  {
3805  IConvertible convertible = value as IConvertible;
3806  if (convertible != null)
3807  {
3808  return convertible.ToString(provider);
3809  }
3810  IFormattable formattable = value as IFormattable;
3811  if (formattable != null)
3812  {
3813  return formattable.ToString(null, provider);
3814  }
3815  if (value != null)
3816  {
3817  return value.ToString();
3818  }
3819  return string.Empty;
3820  }
3821 
3825  [__DynamicallyInvokable]
3826  public static string ToString(bool value)
3827  {
3828  return value.ToString();
3829  }
3830 
3835  [__DynamicallyInvokable]
3836  public static string ToString(bool value, IFormatProvider provider)
3837  {
3838  return value.ToString(provider);
3839  }
3840 
3844  [__DynamicallyInvokable]
3845  public static string ToString(char value)
3846  {
3847  return char.ToString(value);
3848  }
3849 
3854  [__DynamicallyInvokable]
3855  public static string ToString(char value, IFormatProvider provider)
3856  {
3857  return value.ToString(provider);
3858  }
3859 
3863  [CLSCompliant(false)]
3864  [__DynamicallyInvokable]
3865  public static string ToString(sbyte value)
3866  {
3867  return value.ToString(CultureInfo.CurrentCulture);
3868  }
3869 
3874  [CLSCompliant(false)]
3875  [__DynamicallyInvokable]
3876  public static string ToString(sbyte value, IFormatProvider provider)
3877  {
3878  return value.ToString(provider);
3879  }
3880 
3884  [__DynamicallyInvokable]
3885  public static string ToString(byte value)
3886  {
3887  return value.ToString(CultureInfo.CurrentCulture);
3888  }
3889 
3894  [__DynamicallyInvokable]
3895  public static string ToString(byte value, IFormatProvider provider)
3896  {
3897  return value.ToString(provider);
3898  }
3899 
3903  [__DynamicallyInvokable]
3904  public static string ToString(short value)
3905  {
3906  return value.ToString(CultureInfo.CurrentCulture);
3907  }
3908 
3913  [__DynamicallyInvokable]
3914  public static string ToString(short value, IFormatProvider provider)
3915  {
3916  return value.ToString(provider);
3917  }
3918 
3922  [CLSCompliant(false)]
3923  [__DynamicallyInvokable]
3924  public static string ToString(ushort value)
3925  {
3926  return value.ToString(CultureInfo.CurrentCulture);
3927  }
3928 
3933  [CLSCompliant(false)]
3934  [__DynamicallyInvokable]
3935  public static string ToString(ushort value, IFormatProvider provider)
3936  {
3937  return value.ToString(provider);
3938  }
3939 
3943  [__DynamicallyInvokable]
3944  public static string ToString(int value)
3945  {
3946  return value.ToString(CultureInfo.CurrentCulture);
3947  }
3948 
3953  [__DynamicallyInvokable]
3954  public static string ToString(int value, IFormatProvider provider)
3955  {
3956  return value.ToString(provider);
3957  }
3958 
3962  [CLSCompliant(false)]
3963  [__DynamicallyInvokable]
3964  public static string ToString(uint value)
3965  {
3966  return value.ToString(CultureInfo.CurrentCulture);
3967  }
3968 
3973  [CLSCompliant(false)]
3974  [__DynamicallyInvokable]
3975  public static string ToString(uint value, IFormatProvider provider)
3976  {
3977  return value.ToString(provider);
3978  }
3979 
3983  [__DynamicallyInvokable]
3984  public static string ToString(long value)
3985  {
3986  return value.ToString(CultureInfo.CurrentCulture);
3987  }
3988 
3993  [__DynamicallyInvokable]
3994  public static string ToString(long value, IFormatProvider provider)
3995  {
3996  return value.ToString(provider);
3997  }
3998 
4002  [CLSCompliant(false)]
4003  [__DynamicallyInvokable]
4004  public static string ToString(ulong value)
4005  {
4006  return value.ToString(CultureInfo.CurrentCulture);
4007  }
4008 
4013  [CLSCompliant(false)]
4014  [__DynamicallyInvokable]
4015  public static string ToString(ulong value, IFormatProvider provider)
4016  {
4017  return value.ToString(provider);
4018  }
4019 
4023  [__DynamicallyInvokable]
4024  public static string ToString(float value)
4025  {
4026  return value.ToString(CultureInfo.CurrentCulture);
4027  }
4028 
4033  [__DynamicallyInvokable]
4034  public static string ToString(float value, IFormatProvider provider)
4035  {
4036  return value.ToString(provider);
4037  }
4038 
4042  [__DynamicallyInvokable]
4043  public static string ToString(double value)
4044  {
4045  return value.ToString(CultureInfo.CurrentCulture);
4046  }
4047 
4052  [__DynamicallyInvokable]
4053  public static string ToString(double value, IFormatProvider provider)
4054  {
4055  return value.ToString(provider);
4056  }
4057 
4061  [__DynamicallyInvokable]
4062  public static string ToString(decimal value)
4063  {
4064  return value.ToString(CultureInfo.CurrentCulture);
4065  }
4066 
4071  [__DynamicallyInvokable]
4072  public static string ToString(decimal value, IFormatProvider provider)
4073  {
4074  return value.ToString(provider);
4075  }
4076 
4080  [__DynamicallyInvokable]
4081  public static string ToString(DateTime value)
4082  {
4083  return value.ToString();
4084  }
4085 
4090  [__DynamicallyInvokable]
4091  public static string ToString(DateTime value, IFormatProvider provider)
4092  {
4093  return value.ToString(provider);
4094  }
4095 
4100  public static string ToString(string value)
4101  {
4102  return value;
4103  }
4104 
4110  public static string ToString(string value, IFormatProvider provider)
4111  {
4112  return value;
4113  }
4114 
4129  [__DynamicallyInvokable]
4130  public static byte ToByte(string value, int fromBase)
4131  {
4132  if (fromBase != 2 && fromBase != 8 && fromBase != 10 && fromBase != 16)
4133  {
4134  throw new ArgumentException(Environment.GetResourceString("Arg_InvalidBase"));
4135  }
4136  int num = ParseNumbers.StringToInt(value, fromBase, 4608);
4137  if (num < 0 || num > 255)
4138  {
4139  throw new OverflowException(Environment.GetResourceString("Overflow_Byte"));
4140  }
4141  return (byte)num;
4142  }
4143 
4158  [CLSCompliant(false)]
4159  [__DynamicallyInvokable]
4160  public static sbyte ToSByte(string value, int fromBase)
4161  {
4162  if (fromBase != 2 && fromBase != 8 && fromBase != 10 && fromBase != 16)
4163  {
4164  throw new ArgumentException(Environment.GetResourceString("Arg_InvalidBase"));
4165  }
4166  int num = ParseNumbers.StringToInt(value, fromBase, 5120);
4167  if (fromBase != 10 && num <= 255)
4168  {
4169  return (sbyte)num;
4170  }
4171  if (num < -128 || num > 127)
4172  {
4173  throw new OverflowException(Environment.GetResourceString("Overflow_SByte"));
4174  }
4175  return (sbyte)num;
4176  }
4177 
4192  [__DynamicallyInvokable]
4193  public static short ToInt16(string value, int fromBase)
4194  {
4195  if (fromBase != 2 && fromBase != 8 && fromBase != 10 && fromBase != 16)
4196  {
4197  throw new ArgumentException(Environment.GetResourceString("Arg_InvalidBase"));
4198  }
4199  int num = ParseNumbers.StringToInt(value, fromBase, 6144);
4200  if (fromBase != 10 && num <= 65535)
4201  {
4202  return (short)num;
4203  }
4204  if (num < -32768 || num > 32767)
4205  {
4206  throw new OverflowException(Environment.GetResourceString("Overflow_Int16"));
4207  }
4208  return (short)num;
4209  }
4210 
4225  [CLSCompliant(false)]
4226  [__DynamicallyInvokable]
4227  public static ushort ToUInt16(string value, int fromBase)
4228  {
4229  if (fromBase != 2 && fromBase != 8 && fromBase != 10 && fromBase != 16)
4230  {
4231  throw new ArgumentException(Environment.GetResourceString("Arg_InvalidBase"));
4232  }
4233  int num = ParseNumbers.StringToInt(value, fromBase, 4608);
4234  if (num < 0 || num > 65535)
4235  {
4236  throw new OverflowException(Environment.GetResourceString("Overflow_UInt16"));
4237  }
4238  return (ushort)num;
4239  }
4240 
4255  [__DynamicallyInvokable]
4256  public static int ToInt32(string value, int fromBase)
4257  {
4258  if (fromBase != 2 && fromBase != 8 && fromBase != 10 && fromBase != 16)
4259  {
4260  throw new ArgumentException(Environment.GetResourceString("Arg_InvalidBase"));
4261  }
4262  return ParseNumbers.StringToInt(value, fromBase, 4096);
4263  }
4264 
4279  [CLSCompliant(false)]
4280  [__DynamicallyInvokable]
4281  public static uint ToUInt32(string value, int fromBase)
4282  {
4283  if (fromBase != 2 && fromBase != 8 && fromBase != 10 && fromBase != 16)
4284  {
4285  throw new ArgumentException(Environment.GetResourceString("Arg_InvalidBase"));
4286  }
4287  return (uint)ParseNumbers.StringToInt(value, fromBase, 4608);
4288  }
4289 
4304  [__DynamicallyInvokable]
4305  public static long ToInt64(string value, int fromBase)
4306  {
4307  if (fromBase != 2 && fromBase != 8 && fromBase != 10 && fromBase != 16)
4308  {
4309  throw new ArgumentException(Environment.GetResourceString("Arg_InvalidBase"));
4310  }
4311  return ParseNumbers.StringToLong(value, fromBase, 4096);
4312  }
4313 
4328  [CLSCompliant(false)]
4329  [__DynamicallyInvokable]
4330  public static ulong ToUInt64(string value, int fromBase)
4331  {
4332  if (fromBase != 2 && fromBase != 8 && fromBase != 10 && fromBase != 16)
4333  {
4334  throw new ArgumentException(Environment.GetResourceString("Arg_InvalidBase"));
4335  }
4336  return (ulong)ParseNumbers.StringToLong(value, fromBase, 4608);
4337  }
4338 
4345  [SecuritySafeCritical]
4346  [__DynamicallyInvokable]
4347  public static string ToString(byte value, int toBase)
4348  {
4349  if (toBase != 2 && toBase != 8 && toBase != 10 && toBase != 16)
4350  {
4351  throw new ArgumentException(Environment.GetResourceString("Arg_InvalidBase"));
4352  }
4353  return ParseNumbers.IntToString(value, toBase, -1, ' ', 64);
4354  }
4355 
4362  [SecuritySafeCritical]
4363  [__DynamicallyInvokable]
4364  public static string ToString(short value, int toBase)
4365  {
4366  if (toBase != 2 && toBase != 8 && toBase != 10 && toBase != 16)
4367  {
4368  throw new ArgumentException(Environment.GetResourceString("Arg_InvalidBase"));
4369  }
4370  return ParseNumbers.IntToString(value, toBase, -1, ' ', 128);
4371  }
4372 
4379  [SecuritySafeCritical]
4380  [__DynamicallyInvokable]
4381  public static string ToString(int value, int toBase)
4382  {
4383  if (toBase != 2 && toBase != 8 && toBase != 10 && toBase != 16)
4384  {
4385  throw new ArgumentException(Environment.GetResourceString("Arg_InvalidBase"));
4386  }
4387  return ParseNumbers.IntToString(value, toBase, -1, ' ', 0);
4388  }
4389 
4396  [SecuritySafeCritical]
4397  [__DynamicallyInvokable]
4398  public static string ToString(long value, int toBase)
4399  {
4400  if (toBase != 2 && toBase != 8 && toBase != 10 && toBase != 16)
4401  {
4402  throw new ArgumentException(Environment.GetResourceString("Arg_InvalidBase"));
4403  }
4404  return ParseNumbers.LongToString(value, toBase, -1, ' ', 0);
4405  }
4406 
4412  [__DynamicallyInvokable]
4413  public static string ToBase64String(byte[] inArray)
4414  {
4415  if (inArray == null)
4416  {
4417  throw new ArgumentNullException("inArray");
4418  }
4419  return ToBase64String(inArray, 0, inArray.Length, Base64FormattingOptions.None);
4420  }
4421 
4431  [ComVisible(false)]
4432  public static string ToBase64String(byte[] inArray, Base64FormattingOptions options)
4433  {
4434  if (inArray == null)
4435  {
4436  throw new ArgumentNullException("inArray");
4437  }
4438  return ToBase64String(inArray, 0, inArray.Length, options);
4439  }
4440 
4451  [__DynamicallyInvokable]
4452  public static string ToBase64String(byte[] inArray, int offset, int length)
4453  {
4454  return ToBase64String(inArray, offset, length, Base64FormattingOptions.None);
4455  }
4456 
4471  [SecuritySafeCritical]
4472  [ComVisible(false)]
4473  public unsafe static string ToBase64String(byte[] inArray, int offset, int length, Base64FormattingOptions options)
4474  {
4475  if (inArray == null)
4476  {
4477  throw new ArgumentNullException("inArray");
4478  }
4479  if (length < 0)
4480  {
4481  throw new ArgumentOutOfRangeException("length", Environment.GetResourceString("ArgumentOutOfRange_Index"));
4482  }
4483  if (offset < 0)
4484  {
4485  throw new ArgumentOutOfRangeException("offset", Environment.GetResourceString("ArgumentOutOfRange_GenericPositive"));
4486  }
4487  if (options < Base64FormattingOptions.None || options > Base64FormattingOptions.InsertLineBreaks)
4488  {
4489  throw new ArgumentException(Environment.GetResourceString("Arg_EnumIllegalVal", (int)options));
4490  }
4491  int num = inArray.Length;
4492  if (offset > num - length)
4493  {
4494  throw new ArgumentOutOfRangeException("offset", Environment.GetResourceString("ArgumentOutOfRange_OffsetLength"));
4495  }
4496  if (num == 0)
4497  {
4498  return string.Empty;
4499  }
4500  bool insertLineBreaks = options == Base64FormattingOptions.InsertLineBreaks;
4501  int length2 = ToBase64_CalculateAndValidateOutputLength(length, insertLineBreaks);
4502  string text = string.FastAllocateString(length2);
4503  fixed (char* outChars = text)
4504  {
4505  fixed (byte* inData = inArray)
4506  {
4507  int num2 = ConvertToBase64Array(outChars, inData, offset, length, insertLineBreaks);
4508  return text;
4509  }
4510  }
4511  }
4512 
4526  [__DynamicallyInvokable]
4527  public static int ToBase64CharArray(byte[] inArray, int offsetIn, int length, char[] outArray, int offsetOut)
4528  {
4529  return ToBase64CharArray(inArray, offsetIn, length, outArray, offsetOut, Base64FormattingOptions.None);
4530  }
4531 
4549  [SecuritySafeCritical]
4550  [ComVisible(false)]
4551  public unsafe static int ToBase64CharArray(byte[] inArray, int offsetIn, int length, char[] outArray, int offsetOut, Base64FormattingOptions options)
4552  {
4553  if (inArray == null)
4554  {
4555  throw new ArgumentNullException("inArray");
4556  }
4557  if (outArray == null)
4558  {
4559  throw new ArgumentNullException("outArray");
4560  }
4561  if (length < 0)
4562  {
4563  throw new ArgumentOutOfRangeException("length", Environment.GetResourceString("ArgumentOutOfRange_Index"));
4564  }
4565  if (offsetIn < 0)
4566  {
4567  throw new ArgumentOutOfRangeException("offsetIn", Environment.GetResourceString("ArgumentOutOfRange_GenericPositive"));
4568  }
4569  if (offsetOut < 0)
4570  {
4571  throw new ArgumentOutOfRangeException("offsetOut", Environment.GetResourceString("ArgumentOutOfRange_GenericPositive"));
4572  }
4573  if (options < Base64FormattingOptions.None || options > Base64FormattingOptions.InsertLineBreaks)
4574  {
4575  throw new ArgumentException(Environment.GetResourceString("Arg_EnumIllegalVal", (int)options));
4576  }
4577  int num = inArray.Length;
4578  if (offsetIn > num - length)
4579  {
4580  throw new ArgumentOutOfRangeException("offsetIn", Environment.GetResourceString("ArgumentOutOfRange_OffsetLength"));
4581  }
4582  if (num == 0)
4583  {
4584  return 0;
4585  }
4586  bool insertLineBreaks = options == Base64FormattingOptions.InsertLineBreaks;
4587  int num2 = outArray.Length;
4588  int num3 = ToBase64_CalculateAndValidateOutputLength(length, insertLineBreaks);
4589  if (offsetOut > num2 - num3)
4590  {
4591  throw new ArgumentOutOfRangeException("offsetOut", Environment.GetResourceString("ArgumentOutOfRange_OffsetOut"));
4592  }
4593  int result;
4594  fixed (char* outChars = &outArray[offsetOut])
4595  {
4596  fixed (byte* inData = inArray)
4597  {
4598  result = ConvertToBase64Array(outChars, inData, offsetIn, length, insertLineBreaks);
4599  }
4600  }
4601  return result;
4602  }
4603 
4604  [SecurityCritical]
4605  private unsafe static int ConvertToBase64Array(char* outChars, byte* inData, int offset, int length, bool insertLineBreaks)
4606  {
4607  int num = length % 3;
4608  int num2 = offset + (length - num);
4609  int num3 = 0;
4610  int num4 = 0;
4611  char[] array = base64Table;
4612  fixed (char* ptr = array)
4613  {
4614  int i;
4615  for (i = offset; i < num2; i += 3)
4616  {
4617  if (insertLineBreaks)
4618  {
4619  if (num4 == 76)
4620  {
4621  outChars[num3++] = '\r';
4622  outChars[num3++] = '\n';
4623  num4 = 0;
4624  }
4625  num4 += 4;
4626  }
4627  outChars[num3] = ptr[(inData[i] & 0xFC) >> 2];
4628  outChars[num3 + 1] = ptr[((inData[i] & 3) << 4) | ((inData[i + 1] & 0xF0) >> 4)];
4629  outChars[num3 + 2] = ptr[((inData[i + 1] & 0xF) << 2) | ((inData[i + 2] & 0xC0) >> 6)];
4630  outChars[num3 + 3] = ptr[inData[i + 2] & 0x3F];
4631  num3 += 4;
4632  }
4633  i = num2;
4634  if (insertLineBreaks && num != 0 && num4 == 76)
4635  {
4636  outChars[num3++] = '\r';
4637  outChars[num3++] = '\n';
4638  }
4639  switch (num)
4640  {
4641  case 2:
4642  outChars[num3] = ptr[(inData[i] & 0xFC) >> 2];
4643  outChars[num3 + 1] = ptr[((inData[i] & 3) << 4) | ((inData[i + 1] & 0xF0) >> 4)];
4644  outChars[num3 + 2] = ptr[(inData[i + 1] & 0xF) << 2];
4645  outChars[num3 + 3] = ptr[64];
4646  num3 += 4;
4647  break;
4648  case 1:
4649  outChars[num3] = ptr[(inData[i] & 0xFC) >> 2];
4650  outChars[num3 + 1] = ptr[(inData[i] & 3) << 4];
4651  outChars[num3 + 2] = ptr[64];
4652  outChars[num3 + 3] = ptr[64];
4653  num3 += 4;
4654  break;
4655  }
4656  }
4657  return num3;
4658  }
4659 
4660  private static int ToBase64_CalculateAndValidateOutputLength(int inputLength, bool insertLineBreaks)
4661  {
4662  long num = (long)inputLength / 3L * 4;
4663  num += ((inputLength % 3 != 0) ? 4 : 0);
4664  if (num == 0L)
4665  {
4666  return 0;
4667  }
4668  if (insertLineBreaks)
4669  {
4670  long num2 = num / 76;
4671  if (num % 76 == 0L)
4672  {
4673  num2--;
4674  }
4675  num += num2 * 2;
4676  }
4677  if (num > int.MaxValue)
4678  {
4679  throw new OutOfMemoryException();
4680  }
4681  return (int)num;
4682  }
4683 
4690  [SecuritySafeCritical]
4691  [__DynamicallyInvokable]
4692  public unsafe static byte[] FromBase64String(string s)
4693  {
4694  if (s == null)
4695  {
4696  throw new ArgumentNullException("s");
4697  }
4698  fixed (char* inputPtr = s)
4699  {
4700  return FromBase64CharPtr(inputPtr, s.Length);
4701  }
4702  }
4703 
4715  [SecuritySafeCritical]
4716  [__DynamicallyInvokable]
4717  public unsafe static byte[] FromBase64CharArray(char[] inArray, int offset, int length)
4718  {
4719  if (inArray == null)
4720  {
4721  throw new ArgumentNullException("inArray");
4722  }
4723  if (length < 0)
4724  {
4725  throw new ArgumentOutOfRangeException("length", Environment.GetResourceString("ArgumentOutOfRange_Index"));
4726  }
4727  if (offset < 0)
4728  {
4729  throw new ArgumentOutOfRangeException("offset", Environment.GetResourceString("ArgumentOutOfRange_GenericPositive"));
4730  }
4731  if (offset > inArray.Length - length)
4732  {
4733  throw new ArgumentOutOfRangeException("offset", Environment.GetResourceString("ArgumentOutOfRange_OffsetLength"));
4734  }
4735  fixed (char* ptr = inArray)
4736  {
4737  return FromBase64CharPtr(ptr + offset, length);
4738  }
4739  }
4740 
4741  [SecurityCritical]
4742  private unsafe static byte[] FromBase64CharPtr(char* inputPtr, int inputLength)
4743  {
4744  while (inputLength > 0)
4745  {
4746  int num = inputPtr[inputLength - 1];
4747  if (num != 32 && num != 10 && num != 13 && num != 9)
4748  {
4749  break;
4750  }
4751  inputLength--;
4752  }
4753  int num2 = FromBase64_ComputeResultLength(inputPtr, inputLength);
4754  byte[] array = new byte[num2];
4755  byte[] array2 = array;
4756  fixed (byte* startDestPtr = array2)
4757  {
4758  int num3 = FromBase64_Decode(inputPtr, inputLength, startDestPtr, num2);
4759  }
4760  return array;
4761  }
4762 
4763  [SecurityCritical]
4764  private unsafe static int FromBase64_Decode(char* startInputPtr, int inputLength, byte* startDestPtr, int destLength)
4765  {
4766  char* ptr = startInputPtr;
4767  byte* ptr2 = startDestPtr;
4768  char* ptr3 = ptr + inputLength;
4769  byte* ptr4 = ptr2 + destLength;
4770  uint num = 255u;
4771  while (ptr < ptr3)
4772  {
4773  uint num2 = *ptr;
4774  ptr++;
4775  switch (num2)
4776  {
4777  case 9u:
4778  case 10u:
4779  case 13u:
4780  case 32u:
4781  continue;
4782  case 65u:
4783  case 66u:
4784  case 67u:
4785  case 68u:
4786  case 69u:
4787  case 70u:
4788  case 71u:
4789  case 72u:
4790  case 73u:
4791  case 74u:
4792  case 75u:
4793  case 76u:
4794  case 77u:
4795  case 78u:
4796  case 79u:
4797  case 80u:
4798  case 81u:
4799  case 82u:
4800  case 83u:
4801  case 84u:
4802  case 85u:
4803  case 86u:
4804  case 87u:
4805  case 88u:
4806  case 89u:
4807  case 90u:
4808  num2 -= 65;
4809  goto IL_00ba;
4810  case 97u:
4811  case 98u:
4812  case 99u:
4813  case 100u:
4814  case 101u:
4815  case 102u:
4816  case 103u:
4817  case 104u:
4818  case 105u:
4819  case 106u:
4820  case 107u:
4821  case 108u:
4822  case 109u:
4823  case 110u:
4824  case 111u:
4825  case 112u:
4826  case 113u:
4827  case 114u:
4828  case 115u:
4829  case 116u:
4830  case 117u:
4831  case 118u:
4832  case 119u:
4833  case 120u:
4834  case 121u:
4835  case 122u:
4836  num2 -= 71;
4837  goto IL_00ba;
4838  case 48u:
4839  case 49u:
4840  case 50u:
4841  case 51u:
4842  case 52u:
4843  case 53u:
4844  case 54u:
4845  case 55u:
4846  case 56u:
4847  case 57u:
4848  num2 = (uint)((int)num2 - -4);
4849  goto IL_00ba;
4850  case 43u:
4851  num2 = 62u;
4852  goto IL_00ba;
4853  case 47u:
4854  num2 = 63u;
4855  goto IL_00ba;
4856  default:
4857  throw new FormatException(Environment.GetResourceString("Format_BadBase64Char"));
4858  case 61u:
4859  break;
4860  IL_00ba:
4861  num = ((num << 6) | num2);
4862  if (((int)num & int.MinValue) != 0)
4863  {
4864  if ((int)(ptr4 - ptr2) < 3)
4865  {
4866  return -1;
4867  }
4868  *ptr2 = (byte)(num >> 16);
4869  ptr2[1] = (byte)(num >> 8);
4870  ptr2[2] = (byte)num;
4871  ptr2 += 3;
4872  num = 255u;
4873  }
4874  continue;
4875  }
4876  if (ptr == ptr3)
4877  {
4878  num <<= 6;
4879  if (((int)num & int.MinValue) == 0)
4880  {
4881  throw new FormatException(Environment.GetResourceString("Format_BadBase64CharArrayLength"));
4882  }
4883  if ((int)(ptr4 - ptr2) < 2)
4884  {
4885  return -1;
4886  }
4887  byte* intPtr = ptr2;
4888  ptr2 = intPtr + 1;
4889  *intPtr = (byte)(num >> 16);
4890  byte* intPtr2 = ptr2;
4891  ptr2 = intPtr2 + 1;
4892  *intPtr2 = (byte)(num >> 8);
4893  num = 255u;
4894  break;
4895  }
4896  for (; ptr < ptr3 - 1; ptr++)
4897  {
4898  int num3 = *ptr;
4899  if (num3 != 32 && num3 != 10 && num3 != 13 && num3 != 9)
4900  {
4901  break;
4902  }
4903  }
4904  if (ptr == ptr3 - 1 && *ptr == '=')
4905  {
4906  num <<= 12;
4907  if (((int)num & int.MinValue) == 0)
4908  {
4909  throw new FormatException(Environment.GetResourceString("Format_BadBase64CharArrayLength"));
4910  }
4911  if ((int)(ptr4 - ptr2) < 1)
4912  {
4913  return -1;
4914  }
4915  byte* intPtr3 = ptr2;
4916  ptr2 = intPtr3 + 1;
4917  *intPtr3 = (byte)(num >> 16);
4918  num = 255u;
4919  break;
4920  }
4921  throw new FormatException(Environment.GetResourceString("Format_BadBase64Char"));
4922  }
4923  if (num != 255)
4924  {
4925  throw new FormatException(Environment.GetResourceString("Format_BadBase64CharArrayLength"));
4926  }
4927  return (int)(ptr2 - startDestPtr);
4928  }
4929 
4930  [SecurityCritical]
4931  private unsafe static int FromBase64_ComputeResultLength(char* inputPtr, int inputLength)
4932  {
4933  char* ptr = inputPtr + inputLength;
4934  int num = inputLength;
4935  int num2 = 0;
4936  while (inputPtr < ptr)
4937  {
4938  uint num3 = *inputPtr;
4939  inputPtr++;
4940  switch (num3)
4941  {
4942  case 0u:
4943  case 1u:
4944  case 2u:
4945  case 3u:
4946  case 4u:
4947  case 5u:
4948  case 6u:
4949  case 7u:
4950  case 8u:
4951  case 9u:
4952  case 10u:
4953  case 11u:
4954  case 12u:
4955  case 13u:
4956  case 14u:
4957  case 15u:
4958  case 16u:
4959  case 17u:
4960  case 18u:
4961  case 19u:
4962  case 20u:
4963  case 21u:
4964  case 22u:
4965  case 23u:
4966  case 24u:
4967  case 25u:
4968  case 26u:
4969  case 27u:
4970  case 28u:
4971  case 29u:
4972  case 30u:
4973  case 31u:
4974  case 32u:
4975  num--;
4976  break;
4977  case 61u:
4978  num--;
4979  num2++;
4980  break;
4981  }
4982  }
4983  switch (num2)
4984  {
4985  case 1:
4986  num2 = 2;
4987  break;
4988  case 2:
4989  num2 = 1;
4990  break;
4991  default:
4992  throw new FormatException(Environment.GetResourceString("Format_BadBase64Char"));
4993  case 0:
4994  break;
4995  }
4996  return num / 4 * 3 + num2;
4997  }
4998  }
4999 }
static long ToInt64(string value)
Converts the specified string representation of a number to an equivalent 64-bit signed integer.
Definition: Convert.cs:2680
float ToSingle(IFormatProvider provider)
Converts the value of this instance to an equivalent single-precision floating-point number using the...
static sbyte ToSByte(string value)
Converts the specified string representation of a number to an equivalent 8-bit signed integer.
Definition: Convert.cs:1140
Converts a base data type to another base data type.
Definition: Convert.cs:10
static Thread CurrentThread
Gets the currently running thread.
Definition: Thread.cs:134
static DateTime ToDateTime(object value)
Converts the value of the specified object to a T:System.DateTime object.
Definition: Convert.cs:3610
static ulong ToUInt64(string value, int fromBase)
Converts the string representation of a number in a specified base to an equivalent 64-bit unsigned i...
Definition: Convert.cs:4330
static unsafe string ToBase64String(byte[] inArray, int offset, int length, Base64FormattingOptions options)
Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation that...
Definition: Convert.cs:4473
static bool ToBoolean(decimal value)
Converts the value of the specified decimal number to an equivalent Boolean value.
Definition: Convert.cs:646
static short ToInt16(DateTime value)
Calling this method always throws T:System.InvalidCastException.
Definition: Convert.cs:1691
static decimal ToDecimal(bool value)
Converts the specified Boolean value to the equivalent decimal number.
Definition: Convert.cs:3579
static double ToDouble(bool value)
Converts the specified Boolean value to the equivalent double-precision floating-point number.
Definition: Convert.cs:3370
static ushort ToUInt16(ushort value)
Returns the specified 16-bit unsigned integer; no actual conversion is performed.
Definition: Convert.cs:1825
static object ChangeType(object value, Type conversionType)
Returns an object of the specified type and whose value is equivalent to the specified object.
Definition: Convert.cs:336
static short ToInt16(uint value)
Converts the value of the specified 32-bit unsigned integer to an equivalent 16-bit signed integer.
Definition: Convert.cs:1566
static string ToString(char value)
Converts the value of the specified Unicode character to its equivalent string representation.
Definition: Convert.cs:3845
static char ToChar(byte value)
Converts the value of the specified 8-bit unsigned integer to its equivalent Unicode character.
Definition: Convert.cs:737
static decimal ToDecimal(byte value)
Converts the value of the specified 8-bit unsigned integer to the equivalent decimal number.
Definition: Convert.cs:3437
static decimal ToDecimal(DateTime value)
Calling this method always throws T:System.InvalidCastException.
Definition: Convert.cs:3588
static long ToInt64(object value)
Converts the value of the specified object to a 64-bit signed integer.
Definition: Convert.cs:2506
static long ToInt64(float value)
Converts the value of the specified single-precision floating-point number to an equivalent 64-bit si...
Definition: Convert.cs:2643
static char ToChar(short value)
Converts the value of the specified 16-bit signed integer to its equivalent Unicode character.
Definition: Convert.cs:748
static double ToDouble(object value)
Converts the value of the specified object to a double-precision floating-point number.
Definition: Convert.cs:3189
static float ToSingle(byte value)
Converts the value of the specified 8-bit unsigned integer to the equivalent single-precision floatin...
Definition: Convert.cs:3025
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
static string ToString(byte value)
Converts the value of the specified 8-bit unsigned integer to its equivalent string representation.
Definition: Convert.cs:3885
static uint ToUInt32(string value)
Converts the specified string representation of a number to an equivalent 32-bit unsigned integer.
Definition: Convert.cs:2458
static float ToSingle(ushort value)
Converts the value of the specified 16-bit unsigned integer to the equivalent single-precision floati...
Definition: Convert.cs:3053
static string ToString(decimal value)
Converts the value of the specified decimal number to its equivalent string representation.
Definition: Convert.cs:4062
static double ToDouble(string value)
Converts the specified string representation of a number to an equivalent double-precision floating-p...
Definition: Convert.cs:3339
static ulong ToUInt64(char value)
Converts the value of the specified Unicode character to the equivalent 64-bit unsigned integer.
Definition: Convert.cs:2776
static char ToChar(ushort value)
Converts the value of the specified 16-bit unsigned integer to its equivalent Unicode character.
Definition: Convert.cs:762
static byte ToByte(uint value)
Converts the value of the specified 32-bit unsigned integer to an equivalent 8-bit unsigned integer.
Definition: Convert.cs:1322
static DateTime ToDateTime(decimal value)
Calling this method always throws T:System.InvalidCastException.
Definition: Convert.cs:3784
static uint ToUInt32(short value)
Converts the value of the specified 16-bit signed integer to the equivalent 32-bit unsigned integer.
Definition: Convert.cs:2322
static bool ToBoolean(DateTime value)
Calling this method always throws T:System.InvalidCastException.
Definition: Convert.cs:655
static short ToInt16(string value)
Converts the specified string representation of a number to an equivalent 16-bit signed integer.
Definition: Convert.cs:1660
static double ToDouble(int value)
Converts the value of the specified 32-bit signed integer to an equivalent double-precision floating-...
Definition: Convert.cs:3269
static uint ToUInt32(DateTime value)
Calling this method always throws T:System.InvalidCastException.
Definition: Convert.cs:2491
double ToDouble(IFormatProvider provider)
Converts the value of this instance to an equivalent double-precision floating-point number using the...
static short ToInt16(ulong value)
Converts the value of the specified 64-bit unsigned integer to an equivalent 16-bit signed integer.
Definition: Convert.cs:1607
static ulong ToUInt64(DateTime value)
Calling this method always throws T:System.InvalidCastException.
Definition: Convert.cs:2967
static byte ToByte(double value)
Converts the value of the specified double-precision floating-point number to an equivalent 8-bit uns...
Definition: Convert.cs:1381
static double ToDouble(double value)
Returns the specified double-precision floating-point number; no actual conversion is performed.
Definition: Convert.cs:3317
static long ToInt64(short value)
Converts the value of the specified 16-bit signed integer to an equivalent 64-bit signed integer.
Definition: Convert.cs:2576
static int ToInt32(object value, IFormatProvider provider)
Converts the value of the specified object to a 32-bit signed integer, using the specified culture-sp...
Definition: Convert.cs:1994
static DateTime ToDateTime(ushort value)
Calling this method always throws T:System.InvalidCastException.
Definition: Convert.cs:3701
static char ToChar(float value)
Calling this method always throws T:System.InvalidCastException.
Definition: Convert.cs:866
static float ToSingle(string value, IFormatProvider provider)
Converts the specified string representation of a number to an equivalent single-precision floating-p...
Definition: Convert.cs:3152
static string ToString(uint value)
Converts the value of the specified 32-bit unsigned integer to its equivalent string representation.
Definition: Convert.cs:3964
static DateTime ToDateTime(ulong value)
Calling this method always throws T:System.InvalidCastException.
Definition: Convert.cs:3739
static uint ToUInt32(double value)
Converts the value of the specified double-precision floating-point number to an equivalent 32-bit un...
Definition: Convert.cs:2421
static uint ToUInt32(decimal value)
Converts the value of the specified decimal number to an equivalent 32-bit unsigned integer.
Definition: Convert.cs:2444
abstract string FullName
Gets the fully qualified name of the type, including its namespace but not its assembly.
Definition: Type.cs:153
static byte ToByte(bool value)
Converts the specified Boolean value to the equivalent 8-bit unsigned integer.
Definition: Convert.cs:1219
static long ToInt64(decimal value)
Converts the value of the specified decimal number to an equivalent 64-bit signed integer.
Definition: Convert.cs:2667
static readonly DateTime MinValue
Represents the smallest possible value of T:System.DateTime. This field is read-only.
Definition: DateTime.cs:109
static int ToInt32(string value)
Converts the specified string representation of a number to an equivalent 32-bit signed integer.
Definition: Convert.cs:2188
static string ToString(float value)
Converts the value of the specified single-precision floating-point number to its equivalent string r...
Definition: Convert.cs:4024
static bool ToBoolean(byte value)
Converts the value of the specified 8-bit unsigned integer to an equivalent Boolean value.
Definition: Convert.cs:520
bool ToBoolean(IFormatProvider provider)
Converts the value of this instance to an equivalent Boolean value using the specified culture-specif...
TypeCode
Specifies the type of an object.
Definition: TypeCode.cs:9
static ushort ToUInt16(DateTime value)
Calling this method always throws T:System.InvalidCastException.
Definition: Convert.cs:1959
static string ToString(int value)
Converts the value of the specified 32-bit signed integer to its equivalent string representation.
Definition: Convert.cs:3944
static ulong ToUInt64(string value)
Converts the specified string representation of a number to an equivalent 64-bit unsigned integer.
Definition: Convert.cs:2934
static ulong ToUInt64(string value, IFormatProvider provider)
Converts the specified string representation of a number to an equivalent 64-bit unsigned integer,...
Definition: Convert.cs:2953
static DateTime ToDateTime(string value, IFormatProvider provider)
Converts the specified string representation of a number to an equivalent date and time,...
Definition: Convert.cs:3659
static float ToSingle(object value)
Converts the value of the specified object to a single-precision floating-point number.
Definition: Convert.cs:2982
static string ToString(string value)
Returns the specified string instance; no actual conversion is performed.
Definition: Convert.cs:4100
static bool ToBoolean(sbyte value)
Converts the value of the specified 8-bit signed integer to an equivalent Boolean value.
Definition: Convert.cs:501
static decimal ToDecimal(float value)
Converts the value of the specified single-precision floating-point number to the equivalent decimal ...
Definition: Convert.cs:3514
TypeCode GetTypeCode()
Returns the T:System.TypeCode for this instance.
static float ToSingle(object value, IFormatProvider provider)
Converts the value of the specified object to an single-precision floating-point number,...
Definition: Convert.cs:3002
static byte ToByte(int value)
Converts the value of the specified 32-bit signed integer to an equivalent 8-bit unsigned integer.
Definition: Convert.cs:1306
Definition: __Canon.cs:3
static DateTime ToDateTime(object value, IFormatProvider provider)
Converts the value of the specified object to a T:System.DateTime object, using the specified culture...
Definition: Convert.cs:3628
The exception that is thrown when the value of an argument is outside the allowable range of values a...
static bool ToBoolean(uint value)
Converts the value of the specified 32-bit unsigned integer to an equivalent Boolean value.
Definition: Convert.cs:562
static sbyte ToSByte(float value)
Converts the value of the specified single-precision floating-point number to an equivalent 8-bit sig...
Definition: Convert.cs:1100
The exception that is thrown for invalid casting or explicit conversion.
static DateTime ToDateTime(float value)
Calling this method always throws T:System.InvalidCastException.
Definition: Convert.cs:3766
static char ToChar(int value)
Converts the value of the specified 32-bit signed integer to its equivalent Unicode character.
Definition: Convert.cs:773
static uint ToUInt32(char value)
Converts the value of the specified Unicode character to the equivalent 32-bit unsigned integer.
Definition: Convert.cs:2284
static byte ToByte(decimal value)
Converts the value of the specified decimal number to an equivalent 8-bit unsigned integer.
Definition: Convert.cs:1393
static sbyte ToSByte(sbyte value)
Returns the specified 8-bit signed integer; no actual conversion is performed.
Definition: Convert.cs:959
static int ToInt32(decimal value)
Converts the value of the specified decimal number to an equivalent 32-bit signed integer.
Definition: Convert.cs:2175
static char ToChar(ulong value)
Converts the value of the specified 64-bit unsigned integer to its equivalent Unicode character.
Definition: Convert.cs:820
static string ToString(short value)
Converts the value of the specified 16-bit signed integer to its equivalent string representation.
Definition: Convert.cs:3904
static byte ToByte(char value)
Converts the value of the specified Unicode character to the equivalent 8-bit unsigned integer.
Definition: Convert.cs:1244
char ToChar(IFormatProvider provider)
Converts the value of this instance to an equivalent Unicode character using the specified culture-sp...
static ushort ToUInt16(sbyte value)
Converts the value of the specified 8-bit signed integer to the equivalent 16-bit unsigned integer.
Definition: Convert.cs:1768
static ulong ToUInt64(decimal value)
Converts the value of the specified decimal number to an equivalent 64-bit unsigned integer.
Definition: Convert.cs:2920
static int ToInt32(ushort value)
Converts the value of the specified 16-bit unsigned integer to the equivalent 32-bit signed integer.
Definition: Convert.cs:2058
static short ToInt16(string value, int fromBase)
Converts the string representation of a number in a specified base to an equivalent 16-bit signed int...
Definition: Convert.cs:4193
static ushort ToUInt16(double value)
Converts the value of the specified double-precision floating-point number to an equivalent 16-bit un...
Definition: Convert.cs:1899
static long ToInt64(int value)
Converts the value of the specified 32-bit signed integer to an equivalent 64-bit signed integer.
Definition: Convert.cs:2595
static byte ToByte(string value, IFormatProvider provider)
Converts the specified string representation of a number to an equivalent 8-bit unsigned integer,...
Definition: Convert.cs:1424
static float ToSingle(string value)
Converts the specified string representation of a number to an equivalent single-precision floating-p...
Definition: Convert.cs:3134
static string ToString(byte value, IFormatProvider provider)
Converts the value of the specified 8-bit unsigned integer to its equivalent string representation,...
Definition: Convert.cs:3895
static string ToString(ulong value)
Converts the value of the specified 64-bit unsigned integer to its equivalent string representation.
Definition: Convert.cs:4004
static uint ToUInt32(long value)
Converts the value of the specified 64-bit signed integer to an equivalent 32-bit unsigned integer.
Definition: Convert.cs:2375
Provides a mechanism for retrieving an object to control formatting.
static decimal ToDecimal(int value)
Converts the value of the specified 32-bit signed integer to an equivalent decimal number.
Definition: Convert.cs:3474
static long ToInt64(ushort value)
Converts the value of the specified 16-bit unsigned integer to the equivalent 64-bit signed integer.
Definition: Convert.cs:2586
static char ToChar(char value)
Returns the specified Unicode character value; no actual conversion is performed.
Definition: Convert.cs:712
static byte ToByte(short value)
Converts the value of the specified 16-bit signed integer to an equivalent 8-bit unsigned integer.
Definition: Convert.cs:1275
Represents an instant in time, typically expressed as a date and time of day. To browse the ....
Definition: DateTime.cs:13
static uint ToUInt32(uint value)
Returns the specified 32-bit unsigned integer; no actual conversion is performed.
Definition: Convert.cs:2363
static long ToInt64(byte value)
Converts the value of the specified 8-bit unsigned integer to the equivalent 64-bit signed integer.
Definition: Convert.cs:2567
static long ToInt64(ulong value)
Converts the value of the specified 64-bit unsigned integer to an equivalent 64-bit signed integer.
Definition: Convert.cs:2617
static char ToChar(sbyte value)
Converts the value of the specified 8-bit signed integer to its equivalent Unicode character.
Definition: Convert.cs:724
static double ToDouble(short value)
Converts the value of the specified 16-bit signed integer to an equivalent double-precision floating-...
Definition: Convert.cs:3241
static double ToDouble(float value)
Converts the value of the specified single-precision floating-point number to an equivalent double-pr...
Definition: Convert.cs:3307
static sbyte ToSByte(string value, IFormatProvider provider)
Converts the specified string representation of a number to an equivalent 8-bit signed integer,...
Definition: Convert.cs:1161
static decimal ToDecimal(long value)
Converts the value of the specified 64-bit signed integer to an equivalent decimal number.
Definition: Convert.cs:3493
static sbyte ToSByte(char value)
Converts the value of the specified Unicode character to the equivalent 8-bit signed integer.
Definition: Convert.cs:971
DateTime ToDateTime(IFormatProvider provider)
Converts the value of this instance to an equivalent T:System.DateTime using the specified culture-sp...
string ToString(string format, IFormatProvider formatProvider)
Formats the value of the current instance using the specified format.
static ushort ToUInt16(string value)
Converts the specified string representation of a number to an equivalent 16-bit unsigned integer.
Definition: Convert.cs:1926
static uint ToUInt32(string value, int fromBase)
Converts the string representation of a number in a specified base to an equivalent 32-bit unsigned i...
Definition: Convert.cs:4281
sbyte ToSByte(IFormatProvider provider)
Converts the value of this instance to an equivalent 8-bit signed integer using the specified culture...
static bool ToBoolean(int value)
Converts the value of the specified 32-bit signed integer to an equivalent Boolean value.
Definition: Convert.cs:551
static string ToString(bool value)
Converts the specified Boolean value to its equivalent string representation.
Definition: Convert.cs:3826
static char ToChar(long value)
Converts the value of the specified 64-bit signed integer to its equivalent Unicode character.
Definition: Convert.cs:804
static ushort ToUInt16(float value)
Converts the value of the specified single-precision floating-point number to an equivalent 16-bit un...
Definition: Convert.cs:1886
static ulong ToUInt64(object value, IFormatProvider provider)
Converts the value of the specified object to a 64-bit unsigned integer, using the specified culture-...
Definition: Convert.cs:2748
static string ToString(sbyte value, IFormatProvider provider)
Converts the value of the specified 8-bit signed integer to its equivalent string representation,...
Definition: Convert.cs:3876
A type representing a date and time value.
static bool ToBoolean(float value)
Converts the value of the specified single-precision floating-point number to an equivalent Boolean v...
Definition: Convert.cs:626
Base64FormattingOptions
Specifies whether relevant Overload:System.Convert.ToBase64CharArray and Overload:System....
The exception that is thrown when an arithmetic, casting, or conversion operation in a checked contex...
static string ToString(short value, IFormatProvider provider)
Converts the value of the specified 16-bit signed integer to its equivalent string representation,...
Definition: Convert.cs:3914
static string ToString(bool value, IFormatProvider provider)
Converts the specified Boolean value to its equivalent string representation.
Definition: Convert.cs:3836
NumberStyles
Determines the styles permitted in numeric string arguments that are passed to the Parse and TryParse...
Definition: NumberStyles.cs:10
static decimal ToDecimal(string value, IFormatProvider provider)
Converts the specified string representation of a number to an equivalent decimal number,...
Definition: Convert.cs:3556
static short ToInt16(sbyte value)
Converts the value of the specified 8-bit signed integer to the equivalent 16-bit signed integer.
Definition: Convert.cs:1514
static decimal ToDecimal(double value)
Converts the value of the specified double-precision floating-point number to an equivalent decimal n...
Definition: Convert.cs:3525
static uint ToUInt32(string value, IFormatProvider provider)
Converts the specified string representation of a number to an equivalent 32-bit unsigned integer,...
Definition: Convert.cs:2477
static string ToBase64String(byte[] inArray)
Converts an array of 8-bit unsigned integers to its equivalent string representation that is encoded ...
Definition: Convert.cs:4413
static int ToBase64CharArray(byte[] inArray, int offsetIn, int length, char[] outArray, int offsetOut)
Converts a subset of an 8-bit unsigned integer array to an equivalent subset of a Unicode character a...
Definition: Convert.cs:4527
static ulong ToUInt64(long value)
Converts the value of the specified 64-bit signed integer to an equivalent 64-bit unsigned integer.
Definition: Convert.cs:2866
static ushort ToUInt16(char value)
Converts the value of the specified Unicode character to the equivalent 16-bit unsigned integer.
Definition: Convert.cs:1756
static float ToSingle(decimal value)
Converts the value of the specified decimal number to an equivalent single-precision floating-point n...
Definition: Convert.cs:3121
static bool ToBoolean(ulong value)
Converts the value of the specified 64-bit unsigned integer to an equivalent Boolean value.
Definition: Convert.cs:583
static short ToInt16(long value)
Converts the value of the specified 64-bit signed integer to an equivalent 16-bit signed integer.
Definition: Convert.cs:1591
static ushort ToUInt16(string value, IFormatProvider provider)
Converts the specified string representation of a number to an equivalent 16-bit unsigned integer,...
Definition: Convert.cs:1945
static short ToInt16(double value)
Converts the value of the specified double-precision floating-point number to an equivalent 16-bit si...
Definition: Convert.cs:1635
static long ToInt64(long value)
Returns the specified 64-bit signed integer; no actual conversion is performed.
Definition: Convert.cs:2631
static float ToSingle(float value)
Returns the specified single-precision floating-point number; no actual conversion is performed.
Definition: Convert.cs:3101
static double ToDouble(object value, IFormatProvider provider)
Converts the value of the specified object to an double-precision floating-point number,...
Definition: Convert.cs:3209
static bool ToBoolean(short value)
Converts the value of the specified 16-bit signed integer to an equivalent Boolean value.
Definition: Convert.cs:530
static byte ToByte(DateTime value)
Calling this method always throws T:System.InvalidCastException.
Definition: Convert.cs:1437
static int ToInt32(int value)
Returns the specified 32-bit signed integer; no actual conversion is performed.
Definition: Convert.cs:2084
static DateTime ToDateTime(char value)
Calling this method always throws T:System.InvalidCastException.
Definition: Convert.cs:3757
static double ToDouble(uint value)
Converts the value of the specified 32-bit unsigned integer to an equivalent double-precision floatin...
Definition: Convert.cs:3279
static ushort ToUInt16(long value)
Converts the value of the specified 64-bit signed integer to an equivalent 16-bit unsigned integer.
Definition: Convert.cs:1853
static char ToChar(object value)
Converts the value of the specified object to a Unicode character.
Definition: Convert.cs:670
static string ToString(object value, IFormatProvider provider)
Converts the value of the specified object to its equivalent string representation using the specifie...
Definition: Convert.cs:3803
CultureInfo?? CurrentCulture
Gets or sets the culture for the current thread.
Definition: Thread.cs:245
static string ToString(ulong value, IFormatProvider provider)
Converts the value of the specified 64-bit unsigned integer to its equivalent string representation,...
Definition: Convert.cs:4015
static char ToChar(string value, IFormatProvider provider)
Converts the first character of a specified string to a Unicode character, using specified culture-sp...
Definition: Convert.cs:849
Provides information about, and means to manipulate, the current environment and platform....
Definition: Environment.cs:21
static bool ToBoolean(object value)
Converts the value of a specified object to an equivalent Boolean value.
Definition: Convert.cs:457
static DateTime Parse(string s)
Converts the string representation of a date and time to its T:System.DateTime equivalent.
Definition: DateTime.cs:1276
decimal ToDecimal(IFormatProvider provider)
Converts the value of this instance to an equivalent T:System.Decimal number using the specified cult...
static string ToString(int value, IFormatProvider provider)
Converts the value of the specified 32-bit signed integer to its equivalent string representation,...
Definition: Convert.cs:3954
static int ToInt32(string value, IFormatProvider provider)
Converts the specified string representation of a number to an equivalent 32-bit signed integer,...
Definition: Convert.cs:2206
static decimal ToDecimal(string value)
Converts the specified string representation of a number to an equivalent decimal number.
Definition: Convert.cs:3538
The exception that is thrown when the format of an argument is invalid, or when a composite format st...
static ushort ToUInt16(short value)
Converts the value of the specified 16-bit signed integer to the equivalent 16-bit unsigned integer.
Definition: Convert.cs:1794
int ToInt32(IFormatProvider provider)
Converts the value of this instance to an equivalent 32-bit signed integer using the specified cultur...
static float ToSingle(int value)
Converts the value of the specified 32-bit signed integer to an equivalent single-precision floating-...
Definition: Convert.cs:3062
static string ToString(long value, int toBase)
Converts the value of a 64-bit signed integer to its equivalent string representation in a specified ...
Definition: Convert.cs:4398
Provides the base class for enumerations.
Definition: Enum.cs:14
static uint ToUInt32(ulong value)
Converts the value of the specified 64-bit unsigned integer to an equivalent 32-bit unsigned integer.
Definition: Convert.cs:2391
static decimal ToDecimal(ushort value)
Converts the value of the specified 16-bit unsigned integer to an equivalent decimal number.
Definition: Convert.cs:3465
static sbyte ToSByte(int value)
Converts the value of the specified 32-bit signed integer to an equivalent 8-bit signed integer.
Definition: Convert.cs:1035
static char ToChar(DateTime value)
Calling this method always throws T:System.InvalidCastException.
Definition: Convert.cs:893
static char ToChar(decimal value)
Calling this method always throws T:System.InvalidCastException.
Definition: Convert.cs:884
static short ToInt16(int value)
Converts the value of the specified 32-bit signed integer to an equivalent 16-bit signed integer.
Definition: Convert.cs:1550
static readonly DBNull Value
Represents the sole instance of the T:System.DBNull class.
Definition: DBNull.cs:13
static DateTime ToDateTime(int value)
Calling this method always throws T:System.InvalidCastException.
Definition: Convert.cs:3710
static bool ToBoolean(double value)
Converts the value of the specified double-precision floating-point number to an equivalent Boolean v...
Definition: Convert.cs:636
static ulong ToUInt64(ulong value)
Returns the specified 64-bit unsigned integer; no actual conversion is performed.
Definition: Convert.cs:2881
static ulong ToUInt64(int value)
Converts the value of the specified 32-bit signed integer to an equivalent 64-bit unsigned integer.
Definition: Convert.cs:2840
static double Round(double a)
Rounds a double-precision floating-point value to the nearest integral value.
static int ToInt32(ulong value)
Converts the value of the specified 64-bit unsigned integer to an equivalent 32-bit signed integer.
Definition: Convert.cs:2111
static string ToString(ushort value, IFormatProvider provider)
Converts the value of the specified 16-bit unsigned integer to its equivalent string representation,...
Definition: Convert.cs:3935
static object ChangeType(object value, Type conversionType, IFormatProvider provider)
Returns an object of the specified type whose value is equivalent to the specified object....
Definition: Convert.cs:357
static string ToBase64String(byte[] inArray, int offset, int length)
Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation that...
Definition: Convert.cs:4452
static DateTime ToDateTime(uint value)
Calling this method always throws T:System.InvalidCastException.
Definition: Convert.cs:3720
static string ToBase64String(byte[] inArray, Base64FormattingOptions options)
Converts an array of 8-bit unsigned integers to its equivalent string representation that is encoded ...
Definition: Convert.cs:4432
static ushort ToUInt16(object value)
Converts the value of the specified object to a 16-bit unsigned integer.
Definition: Convert.cs:1707
static byte ToByte(ushort value)
Converts the value of the specified 16-bit unsigned integer to an equivalent 8-bit unsigned integer.
Definition: Convert.cs:1291
object ToType(Type conversionType, IFormatProvider provider)
Converts the value of this instance to an T:System.Object of the specified T:System....
static sbyte ToSByte(DateTime value)
Calling this method always throws T:System.InvalidCastException.
Definition: Convert.cs:1171
static sbyte ToSByte(uint value)
Converts the value of the specified 32-bit unsigned integer to an equivalent 8-bit signed integer.
Definition: Convert.cs:1051
static DateTime ToDateTime(DateTime value)
Returns the specified T:System.DateTime object; no actual conversion is performed.
Definition: Convert.cs:3597
static float ToSingle(long value)
Converts the value of the specified 64-bit signed integer to an equivalent single-precision floating-...
Definition: Convert.cs:3081
static sbyte ToSByte(object value)
Converts the value of the specified object to an 8-bit signed integer.
Definition: Convert.cs:909
static string ToString(double value, IFormatProvider provider)
Converts the value of the specified double-precision floating-point number to its equivalent string r...
Definition: Convert.cs:4053
Represents type declarations: class types, interface types, array types, value types,...
Definition: Type.cs:18
static byte ToByte(ulong value)
Converts the value of the specified 64-bit unsigned integer to an equivalent 8-bit unsigned integer.
Definition: Convert.cs:1353
static ulong ToUInt64(float value)
Converts the value of the specified single-precision floating-point number to an equivalent 64-bit un...
Definition: Convert.cs:2894
static bool ToBoolean(ushort value)
Converts the value of the specified 16-bit unsigned integer to an equivalent Boolean value.
Definition: Convert.cs:541
static DateTime ToDateTime(byte value)
Calling this method always throws T:System.InvalidCastException.
Definition: Convert.cs:3682
static float ToSingle(ulong value)
Converts the value of the specified 64-bit unsigned integer to an equivalent single-precision floatin...
Definition: Convert.cs:3091
static string ToString(char value, IFormatProvider provider)
Converts the value of the specified Unicode character to its equivalent string representation,...
Definition: Convert.cs:3855
string ToString(IFormatProvider provider)
Converts the value of this instance to an equivalent T:System.String using the specified culture-spec...
ushort ToUInt16(IFormatProvider provider)
Converts the value of this instance to an equivalent 16-bit unsigned integer using the specified cult...
static double ToDouble(ushort value)
Converts the value of the specified 16-bit unsigned integer to the equivalent double-precision floati...
Definition: Convert.cs:3260
static int ToInt32(bool value)
Converts the specified Boolean value to the equivalent 32-bit signed integer.
Definition: Convert.cs:2007
static ulong ToUInt64(sbyte value)
Converts the value of the specified 8-bit signed integer to the equivalent 64-bit unsigned integer.
Definition: Convert.cs:2788
static object ChangeType(object value, TypeCode typeCode)
Returns an object of the specified type whose value is equivalent to the specified object.
Definition: Convert.cs:155
static uint ToUInt32(int value)
Converts the value of the specified 32-bit signed integer to an equivalent 32-bit unsigned integer.
Definition: Convert.cs:2348
static bool ToBoolean(bool value)
Returns the specified Boolean value; no actual conversion is performed.
Definition: Convert.cs:490
static double ToDouble(decimal value)
Converts the value of the specified decimal number to an equivalent double-precision floating-point n...
Definition: Convert.cs:3326
static byte ToByte(long value)
Converts the value of the specified 64-bit signed integer to an equivalent 8-bit unsigned integer.
Definition: Convert.cs:1337
DateTime IConvertible. ToDateTime(IFormatProvider provider)
Returns the current T:System.DateTime object.
Definition: DateTime.cs:1931
static string ToString(long value, IFormatProvider provider)
Converts the value of the specified 64-bit signed integer to its equivalent string representation,...
Definition: Convert.cs:3994
static uint ToUInt32(object value)
Converts the value of the specified object to a 32-bit unsigned integer.
Definition: Convert.cs:2235
static TypeCode GetTypeCode(object value)
Returns the T:System.TypeCode for the specified object.
Definition: Convert.cs:115
static int ToInt32(float value)
Converts the value of the specified single-precision floating-point number to an equivalent 32-bit si...
Definition: Convert.cs:2127
bool IsValueType
Gets a value indicating whether the T:System.Type is a value type.
Definition: Type.cs:445
static long ToInt64(string value, IFormatProvider provider)
Converts the specified string representation of a number to an equivalent 64-bit signed integer,...
Definition: Convert.cs:2698
static int ToInt32(double value)
Converts the value of the specified double-precision floating-point number to an equivalent 32-bit si...
Definition: Convert.cs:2139
static byte ToByte(sbyte value)
Converts the value of the specified 8-bit signed integer to an equivalent 8-bit unsigned integer.
Definition: Convert.cs:1260
static byte ToByte(byte value)
Returns the specified 8-bit unsigned integer; no actual conversion is performed.
Definition: Convert.cs:1233
static long ToInt64(double value)
Converts the value of the specified double-precision floating-point number to an equivalent 64-bit si...
Definition: Convert.cs:2655
static uint ToUInt32(object value, IFormatProvider provider)
Converts the value of the specified object to a 32-bit unsigned integer, using the specified culture-...
Definition: Convert.cs:2256
short ToInt16(IFormatProvider provider)
Converts the value of this instance to an equivalent 16-bit signed integer using the specified cultur...
static string ToString(double value)
Converts the value of the specified double-precision floating-point number to its equivalent string r...
Definition: Convert.cs:4043
static DateTime ToDateTime(string value)
Converts the specified string representation of a date and time to an equivalent date and time value.
Definition: Convert.cs:3643
static ushort ToUInt16(byte value)
Converts the value of the specified 8-bit unsigned integer to the equivalent 16-bit unsigned integer.
Definition: Convert.cs:1782
static string ToString(float value, IFormatProvider provider)
Converts the value of the specified single-precision floating-point number to its equivalent string r...
Definition: Convert.cs:4034
static decimal ToDecimal(object value)
Converts the value of the specified object to an equivalent decimal number.
Definition: Convert.cs:3394
static long ToInt64(string value, int fromBase)
Converts the string representation of a number in a specified base to an equivalent 64-bit signed int...
Definition: Convert.cs:4305
static short ToInt16(ushort value)
Converts the value of the specified 16-bit unsigned integer to the equivalent 16-bit signed integer.
Definition: Convert.cs:1535
static long ToInt64(sbyte value)
Converts the value of the specified 8-bit signed integer to the equivalent 64-bit signed integer.
Definition: Convert.cs:2558
static byte ToByte(object value, IFormatProvider provider)
Converts the value of the specified object to an 8-bit unsigned integer, using the specified culture-...
Definition: Convert.cs:1206
static ushort ToUInt16(bool value)
Converts the specified Boolean value to the equivalent 16-bit unsigned integer.
Definition: Convert.cs:1742
static CultureInfo CurrentCulture
Gets or sets the T:System.Globalization.CultureInfo object that represents the culture used by the cu...
Definition: CultureInfo.cs:120
long ToInt64(IFormatProvider provider)
Converts the value of this instance to an equivalent 64-bit signed integer using the specified cultur...
The exception that is thrown when one of the arguments provided to a method is not valid.
static short ToInt16(short value)
Returns the specified 16-bit signed integer; no actual conversion is performed.
Definition: Convert.cs:1580
static ulong ToUInt64(double value)
Converts the value of the specified double-precision floating-point number to an equivalent 64-bit un...
Definition: Convert.cs:2907
static float ToSingle(short value)
Converts the value of the specified 16-bit signed integer to an equivalent single-precision floating-...
Definition: Convert.cs:3043
static uint ToUInt32(sbyte value)
Converts the value of the specified 8-bit signed integer to the equivalent 32-bit unsigned integer.
Definition: Convert.cs:2296
static sbyte ToSByte(ushort value)
Converts the value of the specified 16-bit unsigned integer to the equivalent 8-bit signed integer.
Definition: Convert.cs:1019
static int ToInt32(byte value)
Converts the value of the specified 8-bit unsigned integer to the equivalent 32-bit signed integer.
Definition: Convert.cs:2039
static char ToChar(bool value)
Calling this method always throws T:System.InvalidCastException.
Definition: Convert.cs:703
static string ToString(DateTime value, IFormatProvider provider)
Converts the value of the specified T:System.DateTime to its equivalent string representation,...
Definition: Convert.cs:4091
static uint ToUInt32(float value)
Converts the value of the specified single-precision floating-point number to an equivalent 32-bit un...
Definition: Convert.cs:2408
static string ToString(byte value, int toBase)
Converts the value of an 8-bit unsigned integer to its equivalent string representation in a specifie...
Definition: Convert.cs:4347
static long ToInt64(char value)
Converts the value of the specified Unicode character to the equivalent 64-bit signed integer.
Definition: Convert.cs:2548
static decimal ToDecimal(ulong value)
Converts the value of the specified 64-bit unsigned integer to an equivalent decimal number.
Definition: Convert.cs:3503
static decimal ToDecimal(object value, IFormatProvider provider)
Converts the value of the specified object to an equivalent decimal number, using the specified cultu...
Definition: Convert.cs:3414
static bool ToBoolean(string value)
Converts the specified string representation of a logical value to its Boolean equivalent.
Definition: Convert.cs:595
static bool ToBoolean(char value)
Calling this method always throws T:System.InvalidCastException.
Definition: Convert.cs:510
static decimal ToDecimal(decimal value)
Returns the specified decimal number; no actual conversion is performed.
Definition: Convert.cs:3570
static bool ToBoolean(long value)
Converts the value of the specified 64-bit signed integer to an equivalent Boolean value.
Definition: Convert.cs:572
static string ToString(decimal value, IFormatProvider provider)
Converts the value of the specified decimal number to its equivalent string representation,...
Definition: Convert.cs:4072
static byte ToByte(float value)
Converts the value of the specified single-precision floating-point number to an equivalent 8-bit uns...
Definition: Convert.cs:1369
static short ToInt16(object value, IFormatProvider provider)
Converts the value of the specified object to a 16-bit signed integer, using the specified culture-sp...
Definition: Convert.cs:1472
Attribute can be applied to an enumeration.
static sbyte ToSByte(bool value)
Converts the specified Boolean value to the equivalent 8-bit signed integer.
Definition: Convert.cs:944
static char ToChar(string value)
Converts the first character of a specified string to a Unicode character.
Definition: Convert.cs:836
static ushort ToUInt16(uint value)
Converts the value of the specified 32-bit unsigned integer to an equivalent 16-bit unsigned integer.
Definition: Convert.cs:1837
static ulong ToUInt64(ushort value)
Converts the value of the specified 16-bit unsigned integer to the equivalent 64-bit unsigned integer...
Definition: Convert.cs:2828
static unsafe int ToBase64CharArray(byte[] inArray, int offsetIn, int length, char[] outArray, int offsetOut, Base64FormattingOptions options)
Converts a subset of an 8-bit unsigned integer array to an equivalent subset of a Unicode character a...
Definition: Convert.cs:4551
static unsafe byte [] FromBase64String(string s)
Converts the specified string, which encodes binary data as base-64 digits, to an equivalent 8-bit un...
Definition: Convert.cs:4692
static sbyte ToSByte(double value)
Converts the value of the specified double-precision floating-point number to an equivalent 8-bit sig...
Definition: Convert.cs:1113
static ushort ToUInt16(object value, IFormatProvider provider)
Converts the value of the specified object to a 16-bit unsigned integer, using the specified culture-...
Definition: Convert.cs:1728
static long ToInt64(bool value)
Converts the specified Boolean value to the equivalent 64-bit signed integer.
Definition: Convert.cs:2539
static byte ToByte(object value)
Converts the value of the specified object to an 8-bit unsigned integer.
Definition: Convert.cs:1186
static char ToChar(double value)
Calling this method always throws T:System.InvalidCastException.
Definition: Convert.cs:875
static float ToSingle(bool value)
Converts the specified Boolean value to the equivalent single-precision floating-point number.
Definition: Convert.cs:3165
static DateTime ToDateTime(double value)
Calling this method always throws T:System.InvalidCastException.
Definition: Convert.cs:3775
static int ToInt32(uint value)
Converts the value of the specified 32-bit unsigned integer to an equivalent 32-bit signed integer.
Definition: Convert.cs:2070
static string ToString(long value)
Converts the value of the specified 64-bit signed integer to its equivalent string representation.
Definition: Convert.cs:3984
static float ToSingle(uint value)
Converts the value of the specified 32-bit unsigned integer to an equivalent single-precision floatin...
Definition: Convert.cs:3072
static string ToString(ushort value)
Converts the value of the specified 16-bit unsigned integer to its equivalent string representation.
Definition: Convert.cs:3924
static object ChangeType(object value, TypeCode typeCode, IFormatProvider provider)
Returns an object of the specified type whose value is equivalent to the specified object....
Definition: Convert.cs:175
static float ToSingle(sbyte value)
Converts the value of the specified 8-bit signed integer to the equivalent single-precision floating-...
Definition: Convert.cs:3016
static double ToDouble(DateTime value)
Calling this method always throws T:System.InvalidCastException.
Definition: Convert.cs:3379
static char ToChar(uint value)
Converts the value of the specified 32-bit unsigned integer to its equivalent Unicode character.
Definition: Convert.cs:789
static uint ToUInt32(bool value)
Converts the specified Boolean value to the equivalent 32-bit unsigned integer.
Definition: Convert.cs:2270
static int ToInt32(string value, int fromBase)
Converts the string representation of a number in a specified base to an equivalent 32-bit signed int...
Definition: Convert.cs:4256
static short ToInt16(object value)
Converts the value of the specified object to a 16-bit signed integer.
Definition: Convert.cs:1452
static float ToSingle(double value)
Converts the value of the specified double-precision floating-point number to an equivalent single-pr...
Definition: Convert.cs:3111
static long ToInt64(uint value)
Converts the value of the specified 32-bit unsigned integer to an equivalent 64-bit signed integer.
Definition: Convert.cs:2605
static DateTime ToDateTime(short value)
Calling this method always throws T:System.InvalidCastException.
Definition: Convert.cs:3691
static char ToChar(object value, IFormatProvider provider)
Converts the value of the specified object to its equivalent Unicode character, using the specified c...
Definition: Convert.cs:690
static decimal ToDecimal(short value)
Converts the value of the specified 16-bit signed integer to an equivalent decimal number.
Definition: Convert.cs:3455
static string ToString(object value)
Converts the value of the specified object to its equivalent string representation.
Definition: Convert.cs:3793
static sbyte ToSByte(short value)
Converts the value of the specified 16-bit signed integer to the equivalent 8-bit signed integer.
Definition: Convert.cs:1003
static bool ToBoolean(string value, IFormatProvider provider)
Converts the specified string representation of a logical value to its Boolean equivalent,...
Definition: Convert.cs:612
static string ToString(DateTime value)
Converts the value of the specified T:System.DateTime to its equivalent string representation.
Definition: Convert.cs:4081
static short ToInt16(decimal value)
Converts the value of the specified decimal number to an equivalent 16-bit signed integer.
Definition: Convert.cs:1647
static DateTime ToDateTime(long value)
Calling this method always throws T:System.InvalidCastException.
Definition: Convert.cs:3729
static sbyte ToSByte(byte value)
Converts the value of the specified 8-bit unsigned integer to the equivalent 8-bit signed integer.
Definition: Convert.cs:987
static double ToDouble(byte value)
Converts the value of the specified 8-bit unsigned integer to the equivalent double-precision floatin...
Definition: Convert.cs:3232
static DateTime ToDateTime(bool value)
Calling this method always throws T:System.InvalidCastException.
Definition: Convert.cs:3748
static double ToDouble(sbyte value)
Converts the value of the specified 8-bit signed integer to the equivalent double-precision floating-...
Definition: Convert.cs:3223
static byte ToByte(string value, int fromBase)
Converts the string representation of a number in a specified base to an equivalent 8-bit unsigned in...
Definition: Convert.cs:4130
static ulong ToUInt64(uint value)
Converts the value of the specified 32-bit unsigned integer to an equivalent 64-bit unsigned integer.
Definition: Convert.cs:2854
static float ToSingle(char value)
Calling this method always throws T:System.InvalidCastException.
Definition: Convert.cs:3034
static byte ToByte(string value)
Converts the specified string representation of a number to an equivalent 8-bit unsigned integer.
Definition: Convert.cs:1406
static int ToInt32(long value)
Converts the value of the specified 64-bit signed integer to an equivalent 32-bit signed integer.
Definition: Convert.cs:2095
static DateTime ToDateTime(sbyte value)
Calling this method always throws T:System.InvalidCastException.
Definition: Convert.cs:3673
ulong ToUInt64(IFormatProvider provider)
Converts the value of this instance to an equivalent 64-bit unsigned integer using the specified cult...
static ulong ToUInt64(bool value)
Converts the specified Boolean value to the equivalent 64-bit unsigned integer.
Definition: Convert.cs:2762
static ulong ToUInt64(object value)
Converts the value of the specified object to a 64-bit unsigned integer.
Definition: Convert.cs:2727
static double ToDouble(ulong value)
Converts the value of the specified 64-bit unsigned integer to an equivalent double-precision floatin...
Definition: Convert.cs:3298
static string ToString(short value, int toBase)
Converts the value of a 16-bit signed integer to its equivalent string representation in a specified ...
Definition: Convert.cs:4364
static ulong ToUInt64(byte value)
Converts the value of the specified 8-bit unsigned integer to the equivalent 64-bit unsigned integer.
Definition: Convert.cs:2802
static int ToInt32(object value)
Converts the value of the specified object to a 32-bit signed integer.
Definition: Convert.cs:1974
byte ToByte(IFormatProvider provider)
Converts the value of this instance to an equivalent 8-bit unsigned integer using the specified cultu...
Provides constants and static methods for trigonometric, logarithmic, and other common mathematical f...
Definition: Math.cs:10
Provides information about a specific culture (called a locale for unmanaged code development)....
Definition: CultureInfo.cs:16
static unsafe byte [] FromBase64CharArray(char[] inArray, int offset, int length)
Converts a subset of a Unicode character array, which encodes binary data as base-64 digits,...
Definition: Convert.cs:4717
static string ToString(string value, IFormatProvider provider)
Returns the specified string instance; no actual conversion is performed.
Definition: Convert.cs:4110
static sbyte ToSByte(decimal value)
Converts the value of the specified decimal number to an equivalent 8-bit signed integer.
Definition: Convert.cs:1126
Defines methods that convert the value of the implementing reference or value type to a common langua...
Definition: IConvertible.cs:9
static sbyte ToSByte(ulong value)
Converts the value of the specified 64-bit unsigned integer to an equivalent 8-bit signed integer.
Definition: Convert.cs:1083
static ulong ToUInt64(short value)
Converts the value of the specified 16-bit signed integer to the equivalent 64-bit unsigned integer.
Definition: Convert.cs:2814
static double ToDouble(long value)
Converts the value of the specified 64-bit signed integer to an equivalent double-precision floating-...
Definition: Convert.cs:3288
static short ToInt16(string value, IFormatProvider provider)
Converts the specified string representation of a number to an equivalent 16-bit signed integer,...
Definition: Convert.cs:1678
static int ToInt32(short value)
Converts the value of the specified 16-bit signed integer to an equivalent 32-bit signed integer.
Definition: Convert.cs:2048
static ushort ToUInt16(int value)
Converts the value of the specified 32-bit signed integer to an equivalent 16-bit unsigned integer.
Definition: Convert.cs:1810
static sbyte ToSByte(object value, IFormatProvider provider)
Converts the value of the specified object to an 8-bit signed integer, using the specified culture-sp...
Definition: Convert.cs:930
static string ToString(int value, int toBase)
Converts the value of a 32-bit signed integer to its equivalent string representation in a specified ...
Definition: Convert.cs:4381
static short ToInt16(float value)
Converts the value of the specified single-precision floating-point number to an equivalent 16-bit si...
Definition: Convert.cs:1623
static double ToDouble(char value)
Calling this method always throws T:System.InvalidCastException.
Definition: Convert.cs:3250
static double ToDouble(string value, IFormatProvider provider)
Converts the specified string representation of a number to an equivalent double-precision floating-p...
Definition: Convert.cs:3357
static bool IsDBNull(object value)
Returns an indication whether the specified object is of type T:System.DBNull.
Definition: Convert.cs:128
static string ToString(sbyte value)
Converts the value of the specified 8-bit signed integer to its equivalent string representation.
Definition: Convert.cs:3865
static ushort ToUInt16(ulong value)
Converts the value of the specified 64-bit unsigned integer to an equivalent 16-bit unsigned integer.
Definition: Convert.cs:1869
Provides functionality to format the value of an object into a string representation.
Definition: IFormattable.cs:8
static decimal ToDecimal(char value)
Calling this method always throws T:System.InvalidCastException.
Definition: Convert.cs:3446
static short ToInt16(char value)
Converts the value of the specified Unicode character to the equivalent 16-bit signed integer.
Definition: Convert.cs:1500
static uint ToUInt32(ushort value)
Converts the value of the specified 16-bit unsigned integer to the equivalent 32-bit unsigned integer...
Definition: Convert.cs:2336
uint ToUInt32(IFormatProvider provider)
Converts the value of this instance to an equivalent 32-bit unsigned integer using the specified cult...
static short ToInt16(bool value)
Converts the specified Boolean value to the equivalent 16-bit signed integer.
Definition: Convert.cs:1485
static decimal ToDecimal(sbyte value)
Converts the value of the specified 8-bit signed integer to the equivalent decimal number.
Definition: Convert.cs:3428
static int ToInt32(char value)
Converts the value of the specified Unicode character to the equivalent 32-bit signed integer.
Definition: Convert.cs:2020
static int ToInt32(sbyte value)
Converts the value of the specified 8-bit signed integer to the equivalent 32-bit signed integer.
Definition: Convert.cs:2030
static float ToSingle(DateTime value)
Calling this method always throws T:System.InvalidCastException.
Definition: Convert.cs:3174
static ushort ToUInt16(string value, int fromBase)
Converts the string representation of a number in a specified base to an equivalent 16-bit unsigned i...
Definition: Convert.cs:4227
static short ToInt16(byte value)
Converts the value of the specified 8-bit unsigned integer to the equivalent 16-bit signed integer.
Definition: Convert.cs:1523
static decimal ToDecimal(uint value)
Converts the value of the specified 32-bit unsigned integer to an equivalent decimal number.
Definition: Convert.cs:3484
static ushort ToUInt16(decimal value)
Converts the value of the specified decimal number to an equivalent 16-bit unsigned integer.
Definition: Convert.cs:1912
static sbyte ToSByte(string value, int fromBase)
Converts the string representation of a number in a specified base to an equivalent 8-bit signed inte...
Definition: Convert.cs:4160
Represents a nonexistent value. This class cannot be inherited.
Definition: DBNull.cs:10
static bool ToBoolean(object value, IFormatProvider provider)
Converts the value of the specified object to an equivalent Boolean value, using the specified cultur...
Definition: Convert.cs:476
static long ToInt64(DateTime value)
Calling this method always throws T:System.InvalidCastException.
Definition: Convert.cs:2711
static sbyte ToSByte(long value)
Converts the value of the specified 64-bit signed integer to an equivalent 8-bit signed integer.
Definition: Convert.cs:1067
static string ToString(uint value, IFormatProvider provider)
Converts the value of the specified 32-bit unsigned integer to its equivalent string representation,...
Definition: Convert.cs:3975
static uint ToUInt32(byte value)
Converts the value of the specified 8-bit unsigned integer to the equivalent 32-bit unsigned integer.
Definition: Convert.cs:2310
Creates and controls a thread, sets its priority, and gets its status.
Definition: Thread.cs:18
static long ToInt64(object value, IFormatProvider provider)
Converts the value of the specified object to a 64-bit signed integer, using the specified culture-sp...
Definition: Convert.cs:2526
static int ToInt32(DateTime value)
Calling this method always throws T:System.InvalidCastException.
Definition: Convert.cs:2219