NumberFormatInfo.IsReadOnly 属性


获取一个值,该值指示 NumberFormatInfo 对象是否为只读。Gets a value that indicates whether this NumberFormatInfo object is read-only.

 property bool IsReadOnly { bool get(); };
public bool IsReadOnly { get; }
member this.IsReadOnly : bool
Public ReadOnly Property IsReadOnly As Boolean


如果 true 是只读的,则为 NumberFormatInfo;否则为 falsetrue if the NumberFormatInfo is read-only; otherwise, false.


尝试对只读 NumberFormatInfo 的属性执行赋值将导致 InvalidOperationExceptionAttempting to perform an assignment to a property of a read-only NumberFormatInfo causes an InvalidOperationException.

可以调用 Clone 方法,通过只读对象创建读/写 NumberFormatInfo 对象,如下面的示例所示。You can call the Clone method to create a read/write NumberFormatInfo object from a read-only object, as the following example illustrates.

using System;
using System.Globalization;

public class Example
   public static void Main()
      NumberFormatInfo nfi = NumberFormatInfo.CurrentInfo;
      Console.WriteLine("Read-Only: {0}\n", nfi.IsReadOnly);

      NumberFormatInfo nfiw = (NumberFormatInfo) nfi.Clone();
      Console.WriteLine("Read-Only: {0}", nfiw.IsReadOnly);
// The example displays the following output:
//       Read-Only: True
//       Read-Only: False
Imports System.Globalization

Module Example
   Public Sub Main()
      Dim nfi As NumberFormatInfo = NumberFormatInfo.CurrentInfo
      Console.WriteLine("Read-Only: {0}", nfi.IsReadOnly)
      Dim nfiw As NumberFormatInfo = CType(nfi.Clone(), NumberFormatInfo)
      Console.WriteLine("Read-Only: {0}", nfiw.IsReadOnly)
   End Sub
End Module
' The example displays the following output:
'       Read-Only: True
'       Read-Only: False