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

input
start
length

Glossary Item Box

Returns the original byte array provided when the encoding was performed

Syntax

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

Parameters

input
start
length

Example

Library/Library.Test/TestHexEncoding.cs

C#Copy Code
const string hex = "0102030405060708090a0b0c0d0e0f10";
byte[] bin = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };

Assert.AreEqual(hex.Substring(4, 10), HexEncoding.EncodeBytes(bin, 2, 5));
Assert.AreEqual(0, BinaryComparer.Compare(new byte[] { 3, 4, 5, 6 }, HexEncoding.DecodeBytes(hex, 4, 8)));
VB.NETCopy Code
Const  hex As String = "0102030405060708090a0b0c0d0e0f10"
Dim bin As Byte() = New Byte() {1, 2, 3, 4, 5, 6, _
    7, 8, 9, 10, 11, 12, _
    13, 14, 15, 16}

Assert.AreEqual(hex.Substring(4, 10), HexEncoding.EncodeBytes(bin, 2, 5))
Assert.AreEqual(0, BinaryComparer.Compare(New Byte() {3, 4, 5, 6}, HexEncoding.DecodeBytes(hex, 4, 8)))

Requirements

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

See Also

Generated with Document! X 2011 by Innovasys