Вы находитесь на странице: 1из 3
rasn017 BiCorwerter ToSting Metres (Byte) (System) BitConverter.ToString Method (Byte[]) NET Framework (current version) Converts the numeric value of each element of a specified array of bytes to its equivalent hexadecimal string representation. Namespace: System Assembly: mscorlib (in mscorlb all) Syntax ce public static string ToString( byte[] value ) Parameters value Type: System.Bytel] An array of bytes. Return Value Type: System.String A string of hexadecimal pairs separated by hyphens, where each pair represents the corresponding element in value; for example, “7F-2C-4A-00 Exceptions Exception Condition ArgumentNulléxception | value is mull Remarks All the elements of value are converted. The order of hexadecimal stings returned by the ToString method depends on whether the computer architecture is itle-endian or big-endian, thlpesimsch microso.comlen-uslitraryta723497|=vs.110)asp?es-save-lang=1écs-lang=ceharpcode-srippa2 rasr017 ‘BiiConverter ToString Mend (Byte) (System) Examples The following code example corwerts Syte arrays to String objects with the TeString method. ow // Example of the BitConverter.ToString( byte[ ] ) method. using Systen; class BytesTostringDeno { // Display a byte array with a nane. public static void WriteByteArray( byte[ ] bytes, string name ) { const string undertine Console.WriteLine( name ); Console.WeiteLine( underLine.Substring( @, Math.Min( name.Length, underLine.Length ) ) ); Console.WriteLine( BitConverter.ToString( bytes ) ); Console.WriteLine( ); } public static void Main( ) { byte[ ] arrayOne = { ®, 1, 2, 4, 8, 16, 32, 64, 128, 255 }; bytel J arraytwo = ¢ 32, 8, ©, 42, @, 65, @, 125, @, 197, @, 168, 3, 41, 4, 172, 32 }5 bytel J arraythree = ¢ 15, 8, 0, 128, 16, 39, 240, 216, 241, 255, 127 3; bytel J arrayFour = ¢ 15, 2% % 2% 2 16, 2 255, 3, 2 @, 202, 154, 59, 255, 255, 255, 255, 127 ); Console.WeiteLine( "This example of the" + itConverter. Tostring( bytel J) \n" + “nethod generates the following output.\n" )s Weitesytearray( arrayone, “areayOne" )3 WriteBytearray( arrayTwo, “arrayTwo" )3 WriteBytearray( arrayThree, "arrayThree" WriteBytearray( arrayFour, “arrayFour” )3 > > I This exanple of the BitConverter.Tostring( byte[ J ) method generates the following output. arrayone ipsimsch microsot comfen-uslibrary8a733s97(4=vs.110)aspr7es-save-lang=18cs-langresharpicode-srippel2 rasn017 ‘BiiConverter ToString Mend (Byte) (System) 00-01-02-04-@8-10-20-40-80-FF arrayTwo 20-00-80-2A-00-41 -00-7D-0-C5-00-AB-03-29-04-AC-20 arraythree 0F -00-00-80-10-27-FO-08-F1-FF-7F arrayFour 0F -00-00-@8-00-10-0-FF-03-00-00-CA-9A-38-FF-FF-FF-FF-7F ” Version Information Universal Windows Platform Available since 8 .NET Framework ‘Available since 1.1 Portable Class Library Supported in: portable .NET platforms Silverlight Available since 2.0 Windows Phone Silverlight Available since 7.0 Windows Phone Available since 8.1 See Also Tostring Overload BitConverter Class System Namespace Return to top © 2017 Microsoft ipsimsch microsct comien-uslibrary8a733s97(4=vs.110)aspr7es-save-lang=18cs-langresharplcode-srippel2

Вам также может понравиться