BitConverter.ToBoolean メソッド
アセンブリ: mscorlib (mscorlib.dll 内)

Dim value As Byte() Dim startIndex As Integer Dim returnValue As Boolean returnValue = BitConverter.ToBoolean(value, startIndex)
戻り値
value の startIndex にあるバイトが 0 以外の場合は true。それ以外の場合は false。


ToBoolean メソッドを使用して、Byte 配列の要素を Boolean 値に変換するコード例を次に示します。
' Example of the BitConverter.ToBoolean method. Imports System Imports Microsoft.VisualBasic Module BytesToBoolDemo Const formatter As String = "{0,5}{1,16}{2,10}" ' Convert a Byte array element to Boolean and display it. Sub BAToBool( bytes( ) As Byte, index As Integer ) Dim value As Boolean = BitConverter.ToBoolean( bytes, index ) Console.WriteLine( formatter, index, _ BitConverter.ToString( bytes, index, 1 ), value ) End Sub Sub Main( ) Dim byteArray as Byte( ) = _ { 0, 1, 2, 4, 8, 16, 32, 64, 128, 255 } Console.WriteLine( _ "This example of the BitConverter.ToBoolean( Byte( ), " & _ "Integer ) " & vbCrLf & "method generates the " & _ "following output. It converts elements of " & vbCrLf & _ "a Byte array to Boolean values." & vbCrLf ) Console.WriteLine( "initial Byte array" ) Console.WriteLine( "------------------" ) Console.WriteLine( BitConverter.ToString( byteArray ) ) Console.WriteLine( ) Console.WriteLine( formatter, "index", "array element", "Boolean" ) Console.WriteLine( formatter, "-----", "-------------", "-------" ) ' Convert Byte array elements to Boolean values. BAToBool( byteArray, 0 ) BAToBool( byteArray, 1 ) BAToBool( byteArray, 3 ) BAToBool( byteArray, 5 ) BAToBool( byteArray, 8 ) BAToBool( byteArray, 9 ) End Sub End Module ' This example of the BitConverter.ToBoolean( Byte( ), Integer ) ' method generates the following output. It converts elements of ' a Byte array to Boolean values. ' ' initial Byte array ' ------------------ ' 00-01-02-04-08-10-20-40-80-FF ' ' index array element Boolean ' ----- ------------- ------- ' 0 00 False ' 1 01 True ' 3 04 True ' 5 10 True ' 8 80 True ' 9 FF True
// Example of the BitConverter.ToBoolean method. using System; class GetBytesBoolDemo { const string formatter = "{0,5}{1 ,16}{2,10}"; // Convert a byte array element to bool and display it. public static void BAToBool( byte[ ] bytes, int index ) { bool value = BitConverter.ToBoolean( bytes, index ); Console.WriteLine( formatter, index, BitConverter.ToString( bytes, index, 1 ), value ); } public static void Main( ) { byte[ ] byteArray = { 0, 1, 2, 4, 8, 16, 32, 64, 128, 255 }; Console.WriteLine( "This example of the BitConverter.ToBoolean( byte[ ], " + "int ) \nmethod generates the following output. It " + "converts elements \nof a byte array to bool values.\n" ); Console.WriteLine( "initial byte array" ); Console.WriteLine( "------------------" ); Console.WriteLine( BitConverter.ToString( byteArray ) + '\n' ); Console.WriteLine( formatter, "index", "array element", "bool" ); Console.WriteLine( formatter, "-----", "-------------", "----" ); // Convert byte array elements to bool values. BAToBool( byteArray, 0 ); BAToBool( byteArray, 1 ); BAToBool( byteArray, 3 ); BAToBool( byteArray, 5 ); BAToBool( byteArray, 8 ); BAToBool( byteArray, 9 ); } } /* This example of the BitConverter.ToBoolean( byte[ ], int ) method generates the following output. It converts elements of a byte array to bool values. initial byte array ------------------ 00-01-02-04-08-10-20-40-80-FF index array element bool ----- ------------- ---- 0 00 False 1 01 True 3 04 True 5 10 True 8 80 True 9 FF True */
// Example of the BitConverter::ToBoolean method. using namespace System; // Convert a byte array element to bool and display it. void BAToBool( array<unsigned char>^bytes, int index ) { bool value = BitConverter::ToBoolean( bytes, index ); Console::WriteLine( "{0,5}{1,16}{2,10}", index, BitConverter::ToString( bytes, index, 1 ), value ); } int main() { array<unsigned char>^byteArray = {0,1,2,4,8,16,32,64 ,128,255}; Console::WriteLine( "This example of the BitConverter::ToBoolean( unsigned " "char[ ], int ) \nmethod generates the following output. It " "converts elements of a \nbyte array to bool values.\n" ); Console::WriteLine( "initial unsigned char array" ); Console::WriteLine( "---------------------------" ); Console::WriteLine( BitConverter::ToString( byteArray ) ); Console::WriteLine(); Console::WriteLine( "{0,5}{1,16}{2,10}", "index", "array element", "bool" ); Console::WriteLine( "{0,5}{1,16}{2,10}", "-----", "-------------", "----" ); // Convert byte array elements to bool values. BAToBool( byteArray, 0 ); BAToBool( byteArray, 1 ); BAToBool( byteArray, 3 ); BAToBool( byteArray, 5 ); BAToBool( byteArray, 8 ); BAToBool( byteArray, 9 ); } /* This example of the BitConverter::ToBoolean( unsigned char[ ], int ) method generates the following output. It converts elements of a byte array to bool values. initial unsigned char array --------------------------- 00-01-02-04-08-10-20-40-80-FF index array element bool ----- ------------- ---- 0 00 False 1 01 True 3 04 True 5 10 True 8 80 True 9 FF True */
// Example of the BitConverter.ToBoolean method. import System.*; class GetBytesBoolDemo { private static String formatter = "{0 ,5}{1,16}{2,10}"; // Convert a byte array element to bool and display it. public static void BAToBool(ubyte bytes[], int index) { boolean value = BitConverter.ToBoolean(bytes, index); Console.WriteLine(formatter, (Int32)index, BitConverter.ToString(bytes, index, 1), (System.Boolean)value); } //BAToBool public static void main(String[] args) { ubyte byteArray[] = { 0, 1, 2, 4, 8, 16, 32, 64, 128, 255 }; Console.WriteLine(("This example of the " + "BitConverter.ToBoolean( byte[ ], int ) \n" + "method generates the following output." + " It converts elements \nof a byte array to bool values.\n")); Console.WriteLine("initial byte array"); Console.WriteLine("------------------"); Console.WriteLine((BitConverter.ToString(byteArray) + '\n')); Console.WriteLine(formatter, "index", "array element", "bool"); Console.WriteLine(formatter, "-----", "-------------", "----"); // Convert byte array elements to bool values. BAToBool(byteArray, 0); BAToBool(byteArray, 1); BAToBool(byteArray, 3); BAToBool(byteArray, 5); BAToBool(byteArray, 8); BAToBool(byteArray, 9); } //main } //GetBytesBoolDemo /* This example of the BitConverter.ToBoolean( byte[ ], int ) method generates the following output. It converts elements of a byte array to bool values. initial byte array ------------------ 00-01-02-04-08-10-20-40-80-FF index array element bool ----- ------------- ---- 0 00 False 1 01 True 3 04 True 5 10 True 8 80 True 9 FF True */

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からBitConverter.ToBoolean メソッドを検索する場合は、下記のリンクをクリックしてください。

- BitConverter.ToBoolean メソッドのページへのリンク