共用方式為


NumberFormatInfo.IsReadOnly 屬性

定義

取得值,表示這個 NumberFormatInfo 物件是否為唯讀。

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

屬性值

如果 true 是唯讀,則為 NumberFormatInfo,否則為 false

備註

試著對唯讀 NumberFormatInfo 屬性執行指派會導致 InvalidOperationException

您可以呼叫 Clone 方法來從只讀物件建立讀取/寫入 NumberFormatInfo 物件,如下列範例所示。

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)
      Console.WriteLine()
      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

適用於

另請參閱