BitConverterとは? わかりやすく解説

BitConverter クラス

基本データ型バイト配列に、バイト配列基本データ型変換します

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

解説解説
使用例使用例

BitConverter クラス一部メソッド使用方法次のコード例示します

' Example of BitConverter class methods.
Imports System
Imports Microsoft.VisualBasic

Module BitConverterDemo

    Sub Main( )

        Const formatter As String
 = "{0,25}{1,30}"
 
        Dim aDoubl      As Double
   = 0.1111111111111111111
        Dim aSingl      As Single
   = 0.1111111111111111111
        Dim aLong       As Long
     = 1111111111111111111
        Dim anInt       As Integer
  = 1111111111
        Dim aShort      As Short
    = 11111
        Dim aChar       As Char
     = "*"c
        Dim aBool       As Boolean
  = True

        Console.WriteLine( _
            "This example of methods of the BitConverter class"
 & _
            vbCrLf & "generates the following output."
 & vbCrLf )
        Console.WriteLine( formatter, "argument",
 "Byte array" )
        Console.WriteLine( formatter, "--------",
 "----------" )

        ' Convert values to Byte arrays and display them.
        Console.WriteLine( formatter, aDoubl, _
            BitConverter.ToString( BitConverter.GetBytes( aDoubl ) ) )
        Console.WriteLine( formatter, aSingl, _
            BitConverter.ToString( BitConverter.GetBytes( aSingl ) ) )
        Console.WriteLine( formatter, aLong, _
            BitConverter.ToString( BitConverter.GetBytes( aLong ) ) )
        Console.WriteLine( formatter, anInt, _
            BitConverter.ToString( BitConverter.GetBytes( anInt ) ) )
        Console.WriteLine( formatter, aShort, _
            BitConverter.ToString( BitConverter.GetBytes( aShort ) ) )
        Console.WriteLine( formatter, aChar, _
            BitConverter.ToString( BitConverter.GetBytes( aChar ) ) )
        Console.WriteLine( formatter, aBool, _
            BitConverter.ToString( BitConverter.GetBytes( aBool ) ) )
    End Sub
End Module

' This example of methods of the BitConverter class
' generates the following output.
' 
'                  argument                    Byte array
'                  --------                    ----------
'         0.111111111111111       1C-C7-71-1C-C7-71-BC-3F
'                 0.1111111                   39-8E-E3-3D
'       1111111111111111111       C7-71-C4-2B-AB-75-6B-0F
'                1111111111                   C7-35-3A-42
'                     11111                         67-2B
'                         *                         2A-00
'                      True                            01
// Example of BitConverter class methods.
using System;

class BitConverterDemo
{
    public static void Main(
 )
    {
        const string formatter = "{0,25}{1
,30}";
 
        double  aDoubl  = 0.1111111111111111111;
        float   aSingl  = 0.1111111111111111111F;
        long    aLong   = 1111111111111111111;
        int     anInt   = 1111111111;
        short   aShort  = 11111;
        char    aChar   = '*';
        bool    aBool   = true;

        Console.WriteLine( 
            "This example of methods of the BitConverter class"
 +
            "\ngenerates the following output.\n" );
        Console.WriteLine( formatter, "argument", "byte array"
 );
        Console.WriteLine( formatter, "--------", "----------"
 );

        // Convert values to Byte arrays and display them.
        Console.WriteLine( formatter, aDoubl, 
            BitConverter.ToString( BitConverter.GetBytes( aDoubl ) ) );
        Console.WriteLine( formatter, aSingl, 
            BitConverter.ToString( BitConverter.GetBytes( aSingl ) ) );
        Console.WriteLine( formatter, aLong, 
            BitConverter.ToString( BitConverter.GetBytes( aLong ) ) );
        Console.WriteLine( formatter, anInt, 
            BitConverter.ToString( BitConverter.GetBytes( anInt ) ) );
        Console.WriteLine( formatter, aShort, 
            BitConverter.ToString( BitConverter.GetBytes( aShort ) ) );
        Console.WriteLine( formatter, aChar, 
            BitConverter.ToString( BitConverter.GetBytes( aChar ) ) );
        Console.WriteLine( formatter, aBool, 
            BitConverter.ToString( BitConverter.GetBytes( aBool ) ) );
    }
}

/*
This example of methods of the BitConverter class
generates the following output.

                 argument                    byte array
                 --------                    ----------
        0.111111111111111       1C-C7-71-1C-C7-71-BC-3F
                0.1111111                   39-8E-E3-3D
      1111111111111111111       C7-71-C4-2B-AB-75-6B-0F
               1111111111                   C7-35-3A-42
                    11111                         67-2B
                        *                         2A-00
                     True                            01
*/
// Example of BitConverter class methods.
using namespace System;
int main()
{
   String^ formatter = "{0,25}{1,30}";
   double aDoubl = 0.1111111111111111111;
   float aSingl = 0.1111111111111111111F;
   __int64 aLong = 1111111111111111111;
   int anInt = 1111111111;
   short aShort = 11111;
   __wchar_t aChar = L'*';
   bool aBool = true;
   Console::WriteLine( "This example of methods of the BitConverter class"
   "\ngenerates the following output.\n" );
   Console::WriteLine( formatter, "argument", "byte array" );
   Console::WriteLine( formatter, "--------", "----------" );
   
   // Convert values to Byte arrays and display them.
   Console::WriteLine( formatter, aDoubl, BitConverter::ToString( BitConverter::GetBytes(
 aDoubl ) ) );
   Console::WriteLine( formatter, aSingl, BitConverter::ToString( BitConverter::GetBytes(
 aSingl ) ) );
   Console::WriteLine( formatter, aLong, BitConverter::ToString( BitConverter::GetBytes(
 aLong ) ) );
   Console::WriteLine( formatter, anInt, BitConverter::ToString( BitConverter::GetBytes(
 anInt ) ) );
   Console::WriteLine( formatter, aShort, BitConverter::ToString( BitConverter::GetBytes(
 aShort ) ) );
   Console::WriteLine( formatter, aChar, BitConverter::ToString( BitConverter::GetBytes(
 aChar ) ) );
   Console::WriteLine( formatter, aBool, BitConverter::ToString( BitConverter::GetBytes(
 aBool ) ) );
}

/*
This example of methods of the BitConverter class
generates the following output.

                 argument                    byte array
                 --------                    ----------
        0.111111111111111       1C-C7-71-1C-C7-71-BC-3F
                0.1111111                   39-8E-E3-3D
      1111111111111111111       C7-71-C4-2B-AB-75-6B-0F
               1111111111                   C7-35-3A-42
                    11111                         67-2B
                        *                         2A-00
                     True                            01
*/
// Example of BitConverter class methods.
import System.*;

class BitConverterDemo 
{
    public static void main(String[]
 args) 
    {
        final System.String formatter = "{0,25}{1,30}";

        double aDoubl = 0.1111111111111111111;
        float aSingl = 0.1111111111111111111F;
        long aLong = 1111111111111111111L;
        int anInt = 1111111111;
        short aShort = 11111;
        char aChar = '*';
        boolean aBool = true;

        Console.WriteLine(("This example of methods of the BitConverter class"
            + "\ngenerates the following output.\n"));
        Console.WriteLine(formatter, "argument", "byte array");
        Console.WriteLine(formatter, "--------", "----------");

        // Convert values to Byte arrays and display them.
        Console.WriteLine(formatter, (System.Double)aDoubl, 
            BitConverter.ToString(BitConverter.GetBytes(aDoubl)));
        Console.WriteLine(formatter, (System.Single)aSingl, 
            BitConverter.ToString(BitConverter.GetBytes(aSingl)));
        Console.WriteLine(formatter, (Int64)aLong, 
            BitConverter.ToString(BitConverter.GetBytes(aLong)));
        Console.WriteLine(formatter, (Int32)anInt, 
            BitConverter.ToString(BitConverter.GetBytes(anInt)));
        Console.WriteLine(formatter, (Int16)aShort, 
            BitConverter.ToString(BitConverter.GetBytes(aShort)));
        Console.WriteLine(formatter, (System.Char)aChar, 
            BitConverter.ToString(BitConverter.GetBytes(aChar)));
        Console.WriteLine(formatter, (System.Boolean)aBool, 
            BitConverter.ToString(BitConverter.GetBytes(aBool)));
    } //main
} //BitConverterDemo
/*
This example of methods of the BitConverter class
generates the following output.

                 argument                    byte array
                 --------                    ----------
        0.111111111111111       1C-C7-71-1C-C7-71-BC-3F
                0.1111111                   39-8E-E3-3D
      1111111111111111111       C7-71-C4-2B-AB-75-6B-0F
               1111111111                   C7-35-3A-42
                    11111                         67-2B
                        *                         2A-00
                     True                            01
*/
継承階層継承階層
System.Object
  System.BitConverter
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

BitConverter フィールド


BitConverter メソッド


パブリック メソッドパブリック メソッド

  名前 説明
パブリック メソッド DoubleToInt64Bits 指定した倍精度浮動小数点数64 ビット符号付き整数変換します
パブリック メソッド Equals  オーバーロードされます2 つObject インスタンス等しかどうか判断します。 ( Object から継承されます。)
パブリック メソッド GetBytes オーバーロードされます指定したデータバイト配列変換します
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用適してます。 ( Object から継承されます。)
パブリック メソッド GetType  現在のインスタンスType取得します。 ( Object から継承されます。)
パブリック メソッド Int64BitsToDouble 指定した 64 ビット符号付き整数倍精度浮動小数点数変換します
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 ( Object から継承されます。)
パブリック メソッド ToBoolean バイト配列内の指定位置にある 1 バイトから変換されブール値を返します
パブリック メソッド ToChar バイト配列内の指定位置にある 2 バイトから変換されUnicode 文字返します
パブリック メソッド ToDouble バイト配列内の指定位置にある 8 バイトから変換され倍精度浮動小数点数返します
パブリック メソッド ToInt16 バイト配列内の指定位置にある 2 バイトから変換され16 ビット符号付き整数返します
パブリック メソッド ToInt32 バイト配列内の指定位置にある 4 バイトから変換され32 ビット符号付き整数返します
パブリック メソッド ToInt64 バイト配列内の指定位置にある 8 バイトから変換され64 ビット符号付き整数返します
パブリック メソッド ToSingle バイト配列内の指定位置にある 4 バイトから変換され単精度浮動小数点数返します
パブリック メソッド ToString オーバーロードされますバイト配列要素から変換されString返します
パブリック メソッド ToUInt16 バイト配列内の指定位置にある 2 バイトから変換され16 ビット符号なし整数返します
パブリック メソッド ToUInt32 バイト配列内の指定位置にある 4 バイトから変換され32 ビット符号なし整数返します
パブリック メソッド ToUInt64 バイト配列内の指定位置にある 8 バイトから変換され64 ビット符号なし整数返します
参照参照

関連項目

BitConverter クラス
System 名前空間
Byte

BitConverter メンバ

基本データ型バイト配列に、バイト配列基本データ型変換します

BitConverter データ型公開されるメンバを以下の表に示します


パブリック フィールドパブリック フィールド
パブリック メソッドパブリック メソッド
  名前 説明
パブリック メソッド DoubleToInt64Bits 指定した倍精度浮動小数点数64 ビット符号付き整数変換します
パブリック メソッド Equals  オーバーロードされます2 つObject インスタンス等しかどうか判断します。 (Object から継承されます。)
パブリック メソッド GetBytes オーバーロードされます指定したデータバイト配列変換します
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用適してます。 (Object から継承されます。)
パブリック メソッド GetType  現在のインスタンスType取得します。 (Object から継承されます。)
パブリック メソッド Int64BitsToDouble 指定した 64 ビット符号付き整数倍精度浮動小数点数変換します
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 (Object から継承されます。)
パブリック メソッド ToBoolean バイト配列内の指定位置にある 1 バイトから変換されブール値を返します
パブリック メソッド ToChar バイト配列内の指定位置にある 2 バイトから変換されUnicode 文字返します
パブリック メソッド ToDouble バイト配列内の指定位置にある 8 バイトから変換され倍精度浮動小数点数返します
パブリック メソッド ToInt16 バイト配列内の指定位置にある 2 バイトから変換され16 ビット符号付き整数返します
パブリック メソッド ToInt32 バイト配列内の指定位置にある 4 バイトから変換され32 ビット符号付き整数返します
パブリック メソッド ToInt64 バイト配列内の指定位置にある 8 バイトから変換され64 ビット符号付き整数返します
パブリック メソッド ToSingle バイト配列内の指定位置にある 4 バイトから変換され単精度浮動小数点数返します
パブリック メソッド ToString オーバーロードされますバイト配列要素から変換されString返します
パブリック メソッド ToUInt16 バイト配列内の指定位置にある 2 バイトから変換され16 ビット符号なし整数返します
パブリック メソッド ToUInt32 バイト配列内の指定位置にある 4 バイトから変換され32 ビット符号なし整数返します
パブリック メソッド ToUInt64 バイト配列内の指定位置にある 8 バイトから変換され64 ビット符号なし整数返します
参照参照

関連項目

BitConverter クラス
System 名前空間
Byte



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

辞書ショートカット

すべての辞書の索引

「BitConverter」の関連用語

BitConverterのお隣キーワード
検索ランキング

   

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



BitConverterのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS