CultureInfo.Clone メソッドとは? わかりやすく解説

CultureInfo.Clone メソッド

現在の CultureInfo のコピー作成します

名前空間: System.Globalization
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

解説解説
使用例使用例

CultureInfo.Clone が CultureInfo関連付けられている DateTimeFormatInfo インスタンスと NumberFormatInfo インスタンスクローン作成するコードの例次に示します

Imports System
Imports System.Globalization


Public Class SamplesCultureInfo
   
   Public Shared Sub Main()
      
      ' Creates and initializes a CultureInfo.
      Dim myCI As New CultureInfo("en-US",
 False)
      
      ' Clones myCI and modifies the DTFI and NFI instances associated
 with the clone.
      Dim myCIclone As CultureInfo = CType(myCI.Clone(),
 CultureInfo)
      myCIclone.DateTimeFormat.AMDesignator = "a.m."
      myCIclone.DateTimeFormat.DateSeparator = "-"
      myCIclone.NumberFormat.CurrencySymbol = "USD"
      myCIclone.NumberFormat.NumberDecimalDigits = 4
      
      ' Displays the properties of the DTFI and NFI instances associated
 with the original and with the clone. 
      Console.WriteLine("DTFI/NFI PROPERTY" + ControlChars.Tab
 + "ORIGINAL" + ControlChars.Tab + "MODIFIED
 CLONE")
      Console.WriteLine("DTFI.AMDesignator" + ControlChars.Tab
 + "{0}" + ControlChars.Tab + ControlChars.Tab +
 "{1}", myCI.DateTimeFormat.AMDesignator, myCIclone.DateTimeFormat.AMDesignator)
      Console.WriteLine("DTFI.DateSeparator" + ControlChars.Tab
 + "{0}" + ControlChars.Tab + ControlChars.Tab +
 "{1}", myCI.DateTimeFormat.DateSeparator, myCIclone.DateTimeFormat.DateSeparator)
      Console.WriteLine("NFI.CurrencySymbol" + ControlChars.Tab
 + "{0}" + ControlChars.Tab + ControlChars.Tab +
 "{1}", myCI.NumberFormat.CurrencySymbol, myCIclone.NumberFormat.CurrencySymbol)
      Console.WriteLine("NFI.NumberDecimalDigits"
 + ControlChars.Tab + "{0}" + ControlChars.Tab +
 ControlChars.Tab + "{1}", myCI.NumberFormat.NumberDecimalDigits, myCIclone.NumberFormat.NumberDecimalDigits)

   End Sub 'Main 

End Class 'SamplesCultureInfo


' This code produces the following output.
'
' DTFI/NFI PROPERTY       ORIGINAL        MODIFIED CLONE
' DTFI.AMDesignator       AM              a.m.
' DTFI.DateSeparator      /               -
' NFI.CurrencySymbol      $               USD
' NFI.NumberDecimalDigits 2               4
using System;
using System.Globalization;


public class SamplesCultureInfo  {

   public static void Main()
  {

      // Creates and initializes a CultureInfo.
      CultureInfo myCI = new CultureInfo("en-US", false);

      // Clones myCI and modifies the DTFI and NFI instances associated
 with the clone.
      CultureInfo myCIclone = (CultureInfo) myCI.Clone();
      myCIclone.DateTimeFormat.AMDesignator = "a.m.";
      myCIclone.DateTimeFormat.DateSeparator = "-";
      myCIclone.NumberFormat.CurrencySymbol = "USD";
      myCIclone.NumberFormat.NumberDecimalDigits = 4;

      // Displays the properties of the DTFI and NFI instances associated
 with the original and with the clone. 
      Console.WriteLine( "DTFI/NFI PROPERTY\tORIGINAL\tMODIFIED CLONE"
 );
      Console.WriteLine( "DTFI.AMDesignator\t{0}\t\t{1}", myCI.DateTimeFormat.AMDesignator,
 myCIclone.DateTimeFormat.AMDesignator );
      Console.WriteLine( "DTFI.DateSeparator\t{0}\t\t{1}", myCI.DateTimeFormat.DateSeparator,
 myCIclone.DateTimeFormat.DateSeparator );
      Console.WriteLine( "NFI.CurrencySymbol\t{0}\t\t{1}", myCI.NumberFormat.CurrencySymbol,
 myCIclone.NumberFormat.CurrencySymbol );
      Console.WriteLine( "NFI.NumberDecimalDigits\t{0}\t\t{1}", myCI.NumberFormat.NumberDecimalDigits,
 myCIclone.NumberFormat.NumberDecimalDigits );
      
   }

}

/*
This code produces the following output.

DTFI/NFI PROPERTY       ORIGINAL        MODIFIED CLONE
DTFI.AMDesignator       AM              a.m.
DTFI.DateSeparator      /               -
NFI.CurrencySymbol      $               USD
NFI.NumberDecimalDigits 2               4

*/
using namespace System;
using namespace System::Globalization;
int main()
{
   
   // Creates and initializes a CultureInfo.
   CultureInfo^ myCI = gcnew CultureInfo( "en-US",false
 );
   
   // Clones myCI and modifies the DTFI and NFI instances associated
 with the clone.
   CultureInfo^ myCIclone = dynamic_cast<CultureInfo^>(myCI->Clone());
   myCIclone->DateTimeFormat->AMDesignator = "a.m.";
   myCIclone->DateTimeFormat->DateSeparator = "-";
   myCIclone->NumberFormat->CurrencySymbol = "USD";
   myCIclone->NumberFormat->NumberDecimalDigits = 4;
   
   // Displays the properties of the DTFI and NFI instances associated
 with the original and with the clone. 
   Console::WriteLine( "DTFI/NFI PROPERTY\tORIGINAL\tMODIFIED CLONE" );
   Console::WriteLine( "DTFI.AMDesignator\t{0}\t\t{1}", myCI->DateTimeFormat->AMDesignator,
 myCIclone->DateTimeFormat->AMDesignator );
   Console::WriteLine( "DTFI.DateSeparator\t{0}\t\t{1}", myCI->DateTimeFormat->DateSeparator,
 myCIclone->DateTimeFormat->DateSeparator );
   Console::WriteLine( "NFI.CurrencySymbol\t{0}\t\t{1}", myCI->NumberFormat->CurrencySymbol,
 myCIclone->NumberFormat->CurrencySymbol );
   Console::WriteLine( "NFI.NumberDecimalDigits\t{0}\t\t{1}", myCI->NumberFormat->NumberDecimalDigits,
 myCIclone->NumberFormat->NumberDecimalDigits );
}

/*
This code produces the following output.

DTFI/NFI PROPERTY       ORIGINAL        MODIFIED CLONE
DTFI.AMDesignator       AM              a.m.
DTFI.DateSeparator      /               -
NFI.CurrencySymbol      $               USD
NFI.NumberDecimalDigits 2               4
*/
import System.* ;
import System.Globalization.* ;

public class SamplesCultureInfo
{
    public static void main(String[]
 args)
    {
        // Creates and initializes a CultureInfo.
        CultureInfo myCI =  new CultureInfo("en-US",
 false);

        // Clones myCI and modifies the DTFI and NFI instances 
        // associated with the clone.
        CultureInfo myCIclone = ((CultureInfo)(myCI.Clone()));
        myCIclone.get_DateTimeFormat().set_AMDesignator( "a.m.");
        myCIclone.get_DateTimeFormat().set_DateSeparator ("-");
        myCIclone.get_NumberFormat().set_CurrencySymbol("USD");
        myCIclone.get_NumberFormat().set_NumberDecimalDigits(4);

        // Displays the properties of the DTFI and NFI instances associated
 
        // with the original and with the clone. 
        Console.WriteLine("DTFI/NFI PROPERTY\tORIGINAL\tMODIFIED CLONE");
        Console.WriteLine("DTFI.AMDesignator\t{0}\t\t{1}", 
            myCI.get_DateTimeFormat().get_AMDesignator(), 
            myCIclone.get_DateTimeFormat().get_AMDesignator());
        Console.WriteLine("DTFI.DateSeparator\t{0}\t\t{1}", 
            myCI.get_DateTimeFormat().get_DateSeparator(), 
            myCIclone.get_DateTimeFormat().get_DateSeparator());
        Console.WriteLine("NFI.CurrencySymbol\t{0}\t\t{1}", 
            myCI.get_NumberFormat().get_CurrencySymbol(), 
            myCIclone.get_NumberFormat().get_CurrencySymbol());
        Console.WriteLine("NFI.NumberDecimalDigits\t{0}\t\t{1}",
            System.Convert.ToString(
            myCI.get_NumberFormat().get_NumberDecimalDigits()), 
            System.Convert.ToString(
            myCIclone.get_NumberFormat().get_NumberDecimalDigits()));
    } //main
} //SamplesCultureInfo

/*
This code produces the following output.

DTFI/NFI PROPERTY       ORIGINAL        MODIFIED CLONE
DTFI.AMDesignator       AM              a.m.
DTFI.DateSeparator      /               -
NFI.CurrencySymbol      $               USD
NFI.NumberDecimalDigits 2               4
*/
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「CultureInfo.Clone メソッド」の関連用語

CultureInfo.Clone メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



CultureInfo.Clone メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS