CSharpTest.Net
DecodeBytes(String) Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace > HexEncoding Class > DecodeBytes Method : DecodeBytes(String) Method

input

Glossary Item Box

Decodes the ascii text from the bytes provided into the original byte array

Syntax

Visual Basic (Declaration) 
Public Overloads Shared Function DecodeBytes( _
   ByVal input As String _
) As Byte()
C# 
public static byte[] DecodeBytes( 
   string input
)

Parameters

input

Example

Library/Library.Test/TestHexEncoding.cs

C#Copy Code
const string hex = "01-0203-0405\t0607\r\n0809\r0a0b0c\n0d0e0f10 ";
byte[] bin = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };

Assert.AreEqual(0, BinaryComparer.Compare(bin, HexEncoding.DecodeBytes(hex)));
Assert.AreEqual(0, BinaryComparer.Compare(bin, HexEncoding.DecodeBytes(Encoding.ASCII.GetBytes(hex))));
VB.NETCopy Code
Const  hex As String = "01-0203-0405" & vbTab & "0607" & vbCr & vbLf & "0809" & vbCr & "0a0b0c" & vbLf & "0d0e0f10 "
Dim bin As Byte() = New Byte() {1, 2, 3, 4, 5, 6, _
    7, 8, 9, 10, 11, 12, _
    13, 14, 15, 16}

Assert.AreEqual(0, BinaryComparer.Compare(bin, HexEncoding.DecodeBytes(hex)))
Assert.AreEqual(0, BinaryComparer.Compare(bin, HexEncoding.DecodeBytes(Encoding.ASCII.GetBytes(hex))))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys