A int between 0 and 2 inclusive that specifies the format of positive percent values.
Type Reason ArgumentOutOfRangeException The value specified for a set operation is less than 0 or greater than 2. InvalidOperationException The current instance is read-only and a set operation was attempted.
The NumberFormatInfo.PercentPositivePattern property is used with the "P" standard format string to define pattern of positive percentage values. For more information, see Standard Numeric Format Strings. This property has one of the values in the following table. The symbol "%" is the NumberFormatInfo.PercentSymbol and n is a number.
0 |
n % |
1 |
n% |
2 |
%n |
3 |
% n |
The following example demonstrates the effects of different NumberFormatInfo.PercentPositivePattern property values.
C# Example
using System; using System.Globalization; class Test { public static void Main() { NumberFormatInfo nfi = new NumberFormatInfo(); decimal data = .9900m; for (int i = 0; i<=2 ; i++) { nfi.PercentPositivePattern = i; Console.WriteLine("pattern # {0}: {1}",i,data.ToString("P",nfi)); } } }
The output is
pattern # 0: 99.00 %