CSharpTest.Net
HexStream Constructor
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace > HexStream Class : HexStream Constructor

stream
mode

Glossary Item Box

Provides reading and writing to a stream of hexidecimal characters.

Syntax

Visual Basic (Declaration) 
Public Function New( _
   ByVal stream As Stream, _
   ByVal mode As CryptoStreamMode _
)
C# 
public HexStream( 
   Stream stream,
   CryptoStreamMode mode
)

Parameters

stream
mode

Example

Library/Library.Test/TestHexEncoding.cs

C#Copy Code
using (Stream mem = new MemoryStream())
{
    using (Stream io = new HexStream(new NonClosingStream(mem), CryptoStreamMode.Write))
        io.Write(HexEncoding.DecodeBytes(AllHex), 0, AllHex.Length / 2);

    Assert.AreEqual(AllHex.Length, mem.Position);
    mem.Position = 0;
    string test = new StreamReader(mem).ReadToEnd();
    Assert.AreEqual(AllHex, test);
}
VB.NETCopy Code
Using mem As Stream = New MemoryStream()
    Using io As Stream = New HexStream(New NonClosingStream(mem), CryptoStreamMode.Write)
        io.Write(HexEncoding.DecodeBytes(AllHex), 0, AllHex.Length / 2)
    End Using

    Assert.AreEqual(AllHex.Length, mem.Position)
    mem.Position = 0
    Dim test As String = New StreamReader(mem).ReadToEnd()
    Assert.AreEqual(AllHex, test)
End Using

Requirements

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

See Also

Generated with Document! X 2011 by Innovasys