mscorlib(4.0.0.0) API with additions
NumberFormatInfo.cs
3 using System.Security;
4 using System.Threading;
5 
6 namespace System.Globalization
7 {
10  [ComVisible(true)]
11  [__DynamicallyInvokable]
13  {
14  private static volatile NumberFormatInfo invariantInfo;
15 
16  internal int[] numberGroupSizes = new int[1]
17  {
18  3
19  };
20 
21  internal int[] currencyGroupSizes = new int[1]
22  {
23  3
24  };
25 
26  internal int[] percentGroupSizes = new int[1]
27  {
28  3
29  };
30 
31  internal string positiveSign = "+";
32 
33  internal string negativeSign = "-";
34 
35  internal string numberDecimalSeparator = ".";
36 
37  internal string numberGroupSeparator = ",";
38 
39  internal string currencyGroupSeparator = ",";
40 
41  internal string currencyDecimalSeparator = ".";
42 
43  internal string currencySymbol = "¤";
44 
45  internal string ansiCurrencySymbol;
46 
47  internal string nanSymbol = "NaN";
48 
49  internal string positiveInfinitySymbol = "Infinity";
50 
51  internal string negativeInfinitySymbol = "-Infinity";
52 
53  internal string percentDecimalSeparator = ".";
54 
55  internal string percentGroupSeparator = ",";
56 
57  internal string percentSymbol = "%";
58 
59  internal string perMilleSymbol = "‰";
60 
61  [OptionalField(VersionAdded = 2)]
62  internal string[] nativeDigits = new string[10]
63  {
64  "0",
65  "1",
66  "2",
67  "3",
68  "4",
69  "5",
70  "6",
71  "7",
72  "8",
73  "9"
74  };
75 
76  [OptionalField(VersionAdded = 1)]
77  internal int m_dataItem;
78 
79  internal int numberDecimalDigits = 2;
80 
81  internal int currencyDecimalDigits = 2;
82 
83  internal int currencyPositivePattern;
84 
85  internal int currencyNegativePattern;
86 
87  internal int numberNegativePattern = 1;
88 
89  internal int percentPositivePattern;
90 
91  internal int percentNegativePattern;
92 
93  internal int percentDecimalDigits = 2;
94 
95  [OptionalField(VersionAdded = 2)]
96  internal int digitSubstitution = 1;
97 
98  internal bool isReadOnly;
99 
100  [OptionalField(VersionAdded = 1)]
101  internal bool m_useUserOverride;
102 
103  [OptionalField(VersionAdded = 2)]
104  internal bool m_isInvariant;
105 
106  [OptionalField(VersionAdded = 1)]
107  internal bool validForParseAsNumber = true;
108 
109  [OptionalField(VersionAdded = 1)]
110  internal bool validForParseAsCurrency = true;
111 
112  private const NumberStyles InvalidNumberStyles = ~(NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.AllowLeadingSign | NumberStyles.AllowTrailingSign | NumberStyles.AllowParentheses | NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands | NumberStyles.AllowExponent | NumberStyles.AllowCurrencySymbol | NumberStyles.AllowHexSpecifier);
113 
116  [__DynamicallyInvokable]
117  public static NumberFormatInfo InvariantInfo
118  {
119  [__DynamicallyInvokable]
120  get
121  {
122  if (invariantInfo == null)
123  {
124  NumberFormatInfo numberFormatInfo = new NumberFormatInfo();
125  numberFormatInfo.m_isInvariant = true;
126  invariantInfo = ReadOnly(numberFormatInfo);
127  }
128  return invariantInfo;
129  }
130  }
131 
136  [__DynamicallyInvokable]
137  public int CurrencyDecimalDigits
138  {
139  [__DynamicallyInvokable]
140  get
141  {
142  return currencyDecimalDigits;
143  }
144  [__DynamicallyInvokable]
145  set
146  {
147  if (value < 0 || value > 99)
148  {
149  throw new ArgumentOutOfRangeException("CurrencyDecimalDigits", string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("ArgumentOutOfRange_Range"), 0, 99));
150  }
151  VerifyWritable();
152  currencyDecimalDigits = value;
153  }
154  }
155 
161  [__DynamicallyInvokable]
162  public string CurrencyDecimalSeparator
163  {
164  [__DynamicallyInvokable]
165  get
166  {
167  return currencyDecimalSeparator;
168  }
169  [__DynamicallyInvokable]
170  set
171  {
172  VerifyWritable();
173  VerifyDecimalSeparator(value, "CurrencyDecimalSeparator");
174  currencyDecimalSeparator = value;
175  }
176  }
177 
181  [__DynamicallyInvokable]
182  public bool IsReadOnly
183  {
184  [__DynamicallyInvokable]
185  get
186  {
187  return isReadOnly;
188  }
189  }
190 
196  [__DynamicallyInvokable]
197  public int[] CurrencyGroupSizes
198  {
199  [__DynamicallyInvokable]
200  get
201  {
202  return (int[])currencyGroupSizes.Clone();
203  }
204  [__DynamicallyInvokable]
205  set
206  {
207  if (value == null)
208  {
209  throw new ArgumentNullException("CurrencyGroupSizes", Environment.GetResourceString("ArgumentNull_Obj"));
210  }
211  VerifyWritable();
212  int[] groupSize = (int[])value.Clone();
213  CheckGroupSize("CurrencyGroupSizes", groupSize);
214  currencyGroupSizes = groupSize;
215  }
216  }
217 
223  [__DynamicallyInvokable]
224  public int[] NumberGroupSizes
225  {
226  [__DynamicallyInvokable]
227  get
228  {
229  return (int[])numberGroupSizes.Clone();
230  }
231  [__DynamicallyInvokable]
232  set
233  {
234  if (value == null)
235  {
236  throw new ArgumentNullException("NumberGroupSizes", Environment.GetResourceString("ArgumentNull_Obj"));
237  }
238  VerifyWritable();
239  int[] groupSize = (int[])value.Clone();
240  CheckGroupSize("NumberGroupSizes", groupSize);
241  numberGroupSizes = groupSize;
242  }
243  }
244 
250  [__DynamicallyInvokable]
251  public int[] PercentGroupSizes
252  {
253  [__DynamicallyInvokable]
254  get
255  {
256  return (int[])percentGroupSizes.Clone();
257  }
258  [__DynamicallyInvokable]
259  set
260  {
261  if (value == null)
262  {
263  throw new ArgumentNullException("PercentGroupSizes", Environment.GetResourceString("ArgumentNull_Obj"));
264  }
265  VerifyWritable();
266  int[] groupSize = (int[])value.Clone();
267  CheckGroupSize("PercentGroupSizes", groupSize);
268  percentGroupSizes = groupSize;
269  }
270  }
271 
276  [__DynamicallyInvokable]
277  public string CurrencyGroupSeparator
278  {
279  [__DynamicallyInvokable]
280  get
281  {
282  return currencyGroupSeparator;
283  }
284  [__DynamicallyInvokable]
285  set
286  {
287  VerifyWritable();
288  VerifyGroupSeparator(value, "CurrencyGroupSeparator");
289  currencyGroupSeparator = value;
290  }
291  }
292 
297  [__DynamicallyInvokable]
298  public string CurrencySymbol
299  {
300  [__DynamicallyInvokable]
301  get
302  {
303  return currencySymbol;
304  }
305  [__DynamicallyInvokable]
306  set
307  {
308  if (value == null)
309  {
310  throw new ArgumentNullException("CurrencySymbol", Environment.GetResourceString("ArgumentNull_String"));
311  }
312  VerifyWritable();
313  currencySymbol = value;
314  }
315  }
316 
319  [__DynamicallyInvokable]
320  public static NumberFormatInfo CurrentInfo
321  {
322  [__DynamicallyInvokable]
323  get
324  {
326  if (!currentCulture.m_isInherited)
327  {
328  NumberFormatInfo numInfo = currentCulture.numInfo;
329  if (numInfo != null)
330  {
331  return numInfo;
332  }
333  }
334  return (NumberFormatInfo)currentCulture.GetFormat(typeof(NumberFormatInfo));
335  }
336  }
337 
342  [__DynamicallyInvokable]
343  public string NaNSymbol
344  {
345  [__DynamicallyInvokable]
346  get
347  {
348  return nanSymbol;
349  }
350  [__DynamicallyInvokable]
351  set
352  {
353  if (value == null)
354  {
355  throw new ArgumentNullException("NaNSymbol", Environment.GetResourceString("ArgumentNull_String"));
356  }
357  VerifyWritable();
358  nanSymbol = value;
359  }
360  }
361 
366  [__DynamicallyInvokable]
367  public int CurrencyNegativePattern
368  {
369  [__DynamicallyInvokable]
370  get
371  {
372  return currencyNegativePattern;
373  }
374  [__DynamicallyInvokable]
375  set
376  {
377  if (value < 0 || value > 15)
378  {
379  throw new ArgumentOutOfRangeException("CurrencyNegativePattern", string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("ArgumentOutOfRange_Range"), 0, 15));
380  }
381  VerifyWritable();
382  currencyNegativePattern = value;
383  }
384  }
385 
390  [__DynamicallyInvokable]
391  public int NumberNegativePattern
392  {
393  [__DynamicallyInvokable]
394  get
395  {
396  return numberNegativePattern;
397  }
398  [__DynamicallyInvokable]
399  set
400  {
401  if (value < 0 || value > 4)
402  {
403  throw new ArgumentOutOfRangeException("NumberNegativePattern", string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("ArgumentOutOfRange_Range"), 0, 4));
404  }
405  VerifyWritable();
406  numberNegativePattern = value;
407  }
408  }
409 
414  [__DynamicallyInvokable]
415  public int PercentPositivePattern
416  {
417  [__DynamicallyInvokable]
418  get
419  {
420  return percentPositivePattern;
421  }
422  [__DynamicallyInvokable]
423  set
424  {
425  if (value < 0 || value > 3)
426  {
427  throw new ArgumentOutOfRangeException("PercentPositivePattern", string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("ArgumentOutOfRange_Range"), 0, 3));
428  }
429  VerifyWritable();
430  percentPositivePattern = value;
431  }
432  }
433 
438  [__DynamicallyInvokable]
439  public int PercentNegativePattern
440  {
441  [__DynamicallyInvokable]
442  get
443  {
444  return percentNegativePattern;
445  }
446  [__DynamicallyInvokable]
447  set
448  {
449  if (value < 0 || value > 11)
450  {
451  throw new ArgumentOutOfRangeException("PercentNegativePattern", string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("ArgumentOutOfRange_Range"), 0, 11));
452  }
453  VerifyWritable();
454  percentNegativePattern = value;
455  }
456  }
457 
462  [__DynamicallyInvokable]
463  public string NegativeInfinitySymbol
464  {
465  [__DynamicallyInvokable]
466  get
467  {
468  return negativeInfinitySymbol;
469  }
470  [__DynamicallyInvokable]
471  set
472  {
473  if (value == null)
474  {
475  throw new ArgumentNullException("NegativeInfinitySymbol", Environment.GetResourceString("ArgumentNull_String"));
476  }
477  VerifyWritable();
478  negativeInfinitySymbol = value;
479  }
480  }
481 
486  [__DynamicallyInvokable]
487  public string NegativeSign
488  {
489  [__DynamicallyInvokable]
490  get
491  {
492  return negativeSign;
493  }
494  [__DynamicallyInvokable]
495  set
496  {
497  if (value == null)
498  {
499  throw new ArgumentNullException("NegativeSign", Environment.GetResourceString("ArgumentNull_String"));
500  }
501  VerifyWritable();
502  negativeSign = value;
503  }
504  }
505 
510  [__DynamicallyInvokable]
511  public int NumberDecimalDigits
512  {
513  [__DynamicallyInvokable]
514  get
515  {
516  return numberDecimalDigits;
517  }
518  [__DynamicallyInvokable]
519  set
520  {
521  if (value < 0 || value > 99)
522  {
523  throw new ArgumentOutOfRangeException("NumberDecimalDigits", string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("ArgumentOutOfRange_Range"), 0, 99));
524  }
525  VerifyWritable();
526  numberDecimalDigits = value;
527  }
528  }
529 
535  [__DynamicallyInvokable]
536  public string NumberDecimalSeparator
537  {
538  [__DynamicallyInvokable]
539  get
540  {
541  return numberDecimalSeparator;
542  }
543  [__DynamicallyInvokable]
544  set
545  {
546  VerifyWritable();
547  VerifyDecimalSeparator(value, "NumberDecimalSeparator");
548  numberDecimalSeparator = value;
549  }
550  }
551 
556  [__DynamicallyInvokable]
557  public string NumberGroupSeparator
558  {
559  [__DynamicallyInvokable]
560  get
561  {
562  return numberGroupSeparator;
563  }
564  [__DynamicallyInvokable]
565  set
566  {
567  VerifyWritable();
568  VerifyGroupSeparator(value, "NumberGroupSeparator");
569  numberGroupSeparator = value;
570  }
571  }
572 
577  [__DynamicallyInvokable]
578  public int CurrencyPositivePattern
579  {
580  [__DynamicallyInvokable]
581  get
582  {
583  return currencyPositivePattern;
584  }
585  [__DynamicallyInvokable]
586  set
587  {
588  if (value < 0 || value > 3)
589  {
590  throw new ArgumentOutOfRangeException("CurrencyPositivePattern", string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("ArgumentOutOfRange_Range"), 0, 3));
591  }
592  VerifyWritable();
593  currencyPositivePattern = value;
594  }
595  }
596 
601  [__DynamicallyInvokable]
602  public string PositiveInfinitySymbol
603  {
604  [__DynamicallyInvokable]
605  get
606  {
607  return positiveInfinitySymbol;
608  }
609  [__DynamicallyInvokable]
610  set
611  {
612  if (value == null)
613  {
614  throw new ArgumentNullException("PositiveInfinitySymbol", Environment.GetResourceString("ArgumentNull_String"));
615  }
616  VerifyWritable();
617  positiveInfinitySymbol = value;
618  }
619  }
620 
625  [__DynamicallyInvokable]
626  public string PositiveSign
627  {
628  [__DynamicallyInvokable]
629  get
630  {
631  return positiveSign;
632  }
633  [__DynamicallyInvokable]
634  set
635  {
636  if (value == null)
637  {
638  throw new ArgumentNullException("PositiveSign", Environment.GetResourceString("ArgumentNull_String"));
639  }
640  VerifyWritable();
641  positiveSign = value;
642  }
643  }
644 
649  [__DynamicallyInvokable]
650  public int PercentDecimalDigits
651  {
652  [__DynamicallyInvokable]
653  get
654  {
655  return percentDecimalDigits;
656  }
657  [__DynamicallyInvokable]
658  set
659  {
660  if (value < 0 || value > 99)
661  {
662  throw new ArgumentOutOfRangeException("PercentDecimalDigits", string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("ArgumentOutOfRange_Range"), 0, 99));
663  }
664  VerifyWritable();
665  percentDecimalDigits = value;
666  }
667  }
668 
674  [__DynamicallyInvokable]
675  public string PercentDecimalSeparator
676  {
677  [__DynamicallyInvokable]
678  get
679  {
680  return percentDecimalSeparator;
681  }
682  [__DynamicallyInvokable]
683  set
684  {
685  VerifyWritable();
686  VerifyDecimalSeparator(value, "PercentDecimalSeparator");
687  percentDecimalSeparator = value;
688  }
689  }
690 
695  [__DynamicallyInvokable]
696  public string PercentGroupSeparator
697  {
698  [__DynamicallyInvokable]
699  get
700  {
701  return percentGroupSeparator;
702  }
703  [__DynamicallyInvokable]
704  set
705  {
706  VerifyWritable();
707  VerifyGroupSeparator(value, "PercentGroupSeparator");
708  percentGroupSeparator = value;
709  }
710  }
711 
716  [__DynamicallyInvokable]
717  public string PercentSymbol
718  {
719  [__DynamicallyInvokable]
720  get
721  {
722  return percentSymbol;
723  }
724  [__DynamicallyInvokable]
725  set
726  {
727  if (value == null)
728  {
729  throw new ArgumentNullException("PercentSymbol", Environment.GetResourceString("ArgumentNull_String"));
730  }
731  VerifyWritable();
732  percentSymbol = value;
733  }
734  }
735 
740  [__DynamicallyInvokable]
741  public string PerMilleSymbol
742  {
743  [__DynamicallyInvokable]
744  get
745  {
746  return perMilleSymbol;
747  }
748  [__DynamicallyInvokable]
749  set
750  {
751  if (value == null)
752  {
753  throw new ArgumentNullException("PerMilleSymbol", Environment.GetResourceString("ArgumentNull_String"));
754  }
755  VerifyWritable();
756  perMilleSymbol = value;
757  }
758  }
759 
765  [ComVisible(false)]
766  public string[] NativeDigits
767  {
768  get
769  {
770  return (string[])nativeDigits.Clone();
771  }
772  set
773  {
774  VerifyWritable();
775  VerifyNativeDigits(value, "NativeDigits");
776  nativeDigits = value;
777  }
778  }
779 
784  [ComVisible(false)]
786  {
787  get
788  {
789  return (DigitShapes)digitSubstitution;
790  }
791  set
792  {
793  VerifyWritable();
794  VerifyDigitSubstitution(value, "DigitSubstitution");
795  digitSubstitution = (int)value;
796  }
797  }
798 
800  [__DynamicallyInvokable]
802  : this(null)
803  {
804  }
805 
806  [OnSerializing]
807  private void OnSerializing(StreamingContext ctx)
808  {
809  if (numberDecimalSeparator != numberGroupSeparator)
810  {
811  validForParseAsNumber = true;
812  }
813  else
814  {
815  validForParseAsNumber = false;
816  }
817  if (numberDecimalSeparator != numberGroupSeparator && numberDecimalSeparator != currencyGroupSeparator && currencyDecimalSeparator != numberGroupSeparator && currencyDecimalSeparator != currencyGroupSeparator)
818  {
819  validForParseAsCurrency = true;
820  }
821  else
822  {
823  validForParseAsCurrency = false;
824  }
825  }
826 
827  [OnDeserializing]
828  private void OnDeserializing(StreamingContext ctx)
829  {
830  }
831 
832  [OnDeserialized]
833  private void OnDeserialized(StreamingContext ctx)
834  {
835  }
836 
837  private static void VerifyDecimalSeparator(string decSep, string propertyName)
838  {
839  if (decSep == null)
840  {
841  throw new ArgumentNullException(propertyName, Environment.GetResourceString("ArgumentNull_String"));
842  }
843  if (decSep.Length == 0)
844  {
845  throw new ArgumentException(Environment.GetResourceString("Argument_EmptyDecString"));
846  }
847  }
848 
849  private static void VerifyGroupSeparator(string groupSep, string propertyName)
850  {
851  if (groupSep == null)
852  {
853  throw new ArgumentNullException(propertyName, Environment.GetResourceString("ArgumentNull_String"));
854  }
855  }
856 
857  private static void VerifyNativeDigits(string[] nativeDig, string propertyName)
858  {
859  if (nativeDig == null)
860  {
861  throw new ArgumentNullException(propertyName, Environment.GetResourceString("ArgumentNull_Array"));
862  }
863  if (nativeDig.Length != 10)
864  {
865  throw new ArgumentException(Environment.GetResourceString("Argument_InvalidNativeDigitCount"), propertyName);
866  }
867  int num = 0;
868  while (true)
869  {
870  if (num >= nativeDig.Length)
871  {
872  return;
873  }
874  if (nativeDig[num] == null)
875  {
876  throw new ArgumentNullException(propertyName, Environment.GetResourceString("ArgumentNull_ArrayValue"));
877  }
878  if (nativeDig[num].Length != 1)
879  {
880  if (nativeDig[num].Length != 2)
881  {
882  throw new ArgumentException(Environment.GetResourceString("Argument_InvalidNativeDigitValue"), propertyName);
883  }
884  if (!char.IsSurrogatePair(nativeDig[num][0], nativeDig[num][1]))
885  {
886  throw new ArgumentException(Environment.GetResourceString("Argument_InvalidNativeDigitValue"), propertyName);
887  }
888  }
889  if (CharUnicodeInfo.GetDecimalDigitValue(nativeDig[num], 0) != num && CharUnicodeInfo.GetUnicodeCategory(nativeDig[num], 0) != UnicodeCategory.PrivateUse)
890  {
891  break;
892  }
893  num++;
894  }
895  throw new ArgumentException(Environment.GetResourceString("Argument_InvalidNativeDigitValue"), propertyName);
896  }
897 
898  private static void VerifyDigitSubstitution(DigitShapes digitSub, string propertyName)
899  {
900  switch (digitSub)
901  {
902  case DigitShapes.Context:
903  case DigitShapes.None:
904  case DigitShapes.NativeNational:
905  return;
906  }
907  throw new ArgumentException(Environment.GetResourceString("Argument_InvalidDigitSubstitution"), propertyName);
908  }
909 
910  [SecuritySafeCritical]
911  internal NumberFormatInfo(CultureData cultureData)
912  {
913  if (cultureData != null)
914  {
915  cultureData.GetNFIValues(this);
916  if (cultureData.IsInvariantCulture)
917  {
918  m_isInvariant = true;
919  }
920  }
921  }
922 
923  private void VerifyWritable()
924  {
925  if (isReadOnly)
926  {
927  throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ReadOnly"));
928  }
929  }
930 
935  [__DynamicallyInvokable]
936  public static NumberFormatInfo GetInstance(IFormatProvider formatProvider)
937  {
938  CultureInfo cultureInfo = formatProvider as CultureInfo;
939  NumberFormatInfo numInfo;
940  if (cultureInfo != null && !cultureInfo.m_isInherited)
941  {
942  numInfo = cultureInfo.numInfo;
943  if (numInfo != null)
944  {
945  return numInfo;
946  }
947  return cultureInfo.NumberFormat;
948  }
949  numInfo = (formatProvider as NumberFormatInfo);
950  if (numInfo != null)
951  {
952  return numInfo;
953  }
954  if (formatProvider != null)
955  {
956  numInfo = (formatProvider.GetFormat(typeof(NumberFormatInfo)) as NumberFormatInfo);
957  if (numInfo != null)
958  {
959  return numInfo;
960  }
961  }
962  return CurrentInfo;
963  }
964 
967  [__DynamicallyInvokable]
968  public object Clone()
969  {
970  NumberFormatInfo numberFormatInfo = (NumberFormatInfo)MemberwiseClone();
971  numberFormatInfo.isReadOnly = false;
972  return numberFormatInfo;
973  }
974 
975  internal static void CheckGroupSize(string propName, int[] groupSize)
976  {
977  int num = 0;
978  while (true)
979  {
980  if (num >= groupSize.Length)
981  {
982  return;
983  }
984  if (groupSize[num] < 1)
985  {
986  if (num == groupSize.Length - 1 && groupSize[num] == 0)
987  {
988  return;
989  }
990  throw new ArgumentException(Environment.GetResourceString("Argument_InvalidGroupSize"), propName);
991  }
992  if (groupSize[num] > 9)
993  {
994  break;
995  }
996  num++;
997  }
998  throw new ArgumentException(Environment.GetResourceString("Argument_InvalidGroupSize"), propName);
999  }
1000 
1004  [__DynamicallyInvokable]
1005  public object GetFormat(Type formatType)
1006  {
1007  if (!(formatType == typeof(NumberFormatInfo)))
1008  {
1009  return null;
1010  }
1011  return this;
1012  }
1013 
1019  [__DynamicallyInvokable]
1021  {
1022  if (nfi == null)
1023  {
1024  throw new ArgumentNullException("nfi");
1025  }
1026  if (nfi.IsReadOnly)
1027  {
1028  return nfi;
1029  }
1030  NumberFormatInfo numberFormatInfo = (NumberFormatInfo)nfi.MemberwiseClone();
1031  numberFormatInfo.isReadOnly = true;
1032  return numberFormatInfo;
1033  }
1034 
1035  internal static void ValidateParseStyleInteger(NumberStyles style)
1036  {
1037  if ((style & ~(NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.AllowLeadingSign | NumberStyles.AllowTrailingSign | NumberStyles.AllowParentheses | NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands | NumberStyles.AllowExponent | NumberStyles.AllowCurrencySymbol | NumberStyles.AllowHexSpecifier)) != 0)
1038  {
1039  throw new ArgumentException(Environment.GetResourceString("Argument_InvalidNumberStyles"), "style");
1040  }
1041  if ((style & NumberStyles.AllowHexSpecifier) != 0 && (style & ~(NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.AllowHexSpecifier)) != 0)
1042  {
1043  throw new ArgumentException(Environment.GetResourceString("Arg_InvalidHexStyle"));
1044  }
1045  }
1046 
1047  internal static void ValidateParseStyleFloatingPoint(NumberStyles style)
1048  {
1049  if ((style & ~(NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.AllowLeadingSign | NumberStyles.AllowTrailingSign | NumberStyles.AllowParentheses | NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands | NumberStyles.AllowExponent | NumberStyles.AllowCurrencySymbol | NumberStyles.AllowHexSpecifier)) != 0)
1050  {
1051  throw new ArgumentException(Environment.GetResourceString("Argument_InvalidNumberStyles"), "style");
1052  }
1053  if ((style & NumberStyles.AllowHexSpecifier) != 0)
1054  {
1055  throw new ArgumentException(Environment.GetResourceString("Arg_HexStyleNotSupported"));
1056  }
1057  }
1058  }
1059 }
static Thread CurrentThread
Gets the currently running thread.
Definition: Thread.cs:134
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
virtual object GetFormat(Type formatType)
Gets an object that defines how to format the specified type.
string PerMilleSymbol
Gets or sets the string to use as the per mille symbol.
DigitShapes DigitSubstitution
Gets or sets a value that specifies how the graphical user interface displays the shape of a digit.
object GetFormat(Type formatType)
Returns an object that provides formatting services for the specified type.
NumberFormatInfo()
Initializes a new writable instance of the T:System.Globalization.NumberFormatInfo class that is cult...
string PercentSymbol
Gets or sets the string to use as the percent symbol.
int [] NumberGroupSizes
Gets or sets the number of digits in each group to the left of the decimal in numeric values.
string NaNSymbol
Gets or sets the string that represents the IEEE NaN (not a number) value.
Definition: __Canon.cs:3
string [] NativeDigits
Gets or sets a string array of native digits equivalent to the Western digits 0 through 9.
The exception that is thrown when the value of an argument is outside the allowable range of values a...
string NegativeSign
Gets or sets the string that denotes that the associated number is negative.
string NumberGroupSeparator
Gets or sets the string that separates groups of digits to the left of the decimal in numeric values.
Provides a mechanism for retrieving an object to control formatting.
string PercentGroupSeparator
Gets or sets the string that separates groups of digits to the left of the decimal in percent values.
int PercentDecimalDigits
Gets or sets the number of decimal places to use in percent values.
Describes the source and destination of a given serialized stream, and provides an additional caller-...
static NumberFormatInfo CurrentInfo
Gets a read-only T:System.Globalization.NumberFormatInfo that formats values based on the current cul...
string CurrencyDecimalSeparator
Gets or sets the string to use as the decimal separator in currency values.
NumberStyles
Determines the styles permitted in numeric string arguments that are passed to the Parse and TryParse...
Definition: NumberStyles.cs:10
string NegativeInfinitySymbol
Gets or sets the string that represents negative infinity.
int PercentPositivePattern
Gets or sets the format pattern for positive percent values.
CultureInfo?? CurrentCulture
Gets or sets the culture for the current thread.
Definition: Thread.cs:245
Provides information about, and means to manipulate, the current environment and platform....
Definition: Environment.cs:21
bool IsReadOnly
Gets a value that indicates whether this T:System.Globalization.NumberFormatInfo object is read-only.
int CurrencyDecimalDigits
Gets or sets the number of decimal places to use in currency values.
static NumberFormatInfo GetInstance(IFormatProvider formatProvider)
Gets the T:System.Globalization.NumberFormatInfo associated with the specified T:System....
string PositiveSign
Gets or sets the string that denotes that the associated number is positive.
Supports cloning, which creates a new instance of a class with the same value as an existing instance...
Definition: ICloneable.cs:7
int NumberNegativePattern
Gets or sets the format pattern for negative numeric values.
Format character that affects the layout of text or the operation of text processes,...
static NumberFormatInfo ReadOnly(NumberFormatInfo nfi)
Returns a read-only T:System.Globalization.NumberFormatInfo wrapper.
Represents type declarations: class types, interface types, array types, value types,...
Definition: Type.cs:18
string CurrencySymbol
Gets or sets the string to use as the currency symbol.
int CurrencyNegativePattern
Gets or sets the format pattern for negative currency values.
DigitShapes
Specifies the culture-specific display of digits.
Definition: DigitShapes.cs:8
int [] CurrencyGroupSizes
Gets or sets the number of digits in each group to the left of the decimal in currency values.
string NumberDecimalSeparator
Gets or sets the string to use as the decimal separator in numeric values.
static CultureInfo CurrentCulture
Gets or sets the T:System.Globalization.CultureInfo object that represents the culture used by the cu...
Definition: CultureInfo.cs:120
The exception that is thrown when one of the arguments provided to a method is not valid.
UnicodeCategory
Defines the Unicode category of a character.
int NumberDecimalDigits
Gets or sets the number of decimal places to use in numeric values.
string CurrencyGroupSeparator
Gets or sets the string that separates groups of digits to the left of the decimal in currency values...
string PositiveInfinitySymbol
Gets or sets the string that represents positive infinity.
object GetFormat(Type formatType)
Gets an object of the specified type that provides a number formatting service.
Specifies that the class can be serialized.
virtual NumberFormatInfo NumberFormat
Gets or sets a T:System.Globalization.NumberFormatInfo that defines the culturally appropriate format...
Definition: CultureInfo.cs:533
int PercentNegativePattern
Gets or sets the format pattern for negative percent values.
Provides information about a specific culture (called a locale for unmanaged code development)....
Definition: CultureInfo.cs:16
int [] PercentGroupSizes
Gets or sets the number of digits in each group to the left of the decimal in percent values.
static NumberFormatInfo InvariantInfo
Gets a read-only T:System.Globalization.NumberFormatInfo object that is culture-independent (invarian...
int CurrencyPositivePattern
Gets or sets the format pattern for positive currency values.
object Clone()
Creates a shallow copy of the T:System.Globalization.NumberFormatInfo object.
Provides culture-specific information for formatting and parsing numeric values.
string PercentDecimalSeparator
Gets or sets the string to use as the decimal separator in percent values.
Creates and controls a thread, sets its priority, and gets its status.
Definition: Thread.cs:18