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

Glossary Item Box

Provides reading and writing to a stream of hexidecimal characters.

Syntax

Visual Basic (Declaration) 
Public Class HexStream 
   Inherits System.Security.Cryptography.CryptoStream
C# 
public class HexStream : System.Security.Cryptography.CryptoStream 

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

Inheritance Hierarchy

System.Object
   System.MarshalByRefObject
      System.IO.Stream
         System.Security.Cryptography.CryptoStream
            CSharpTest.Net.Formatting.HexStream

Requirements

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

See Also

Generated with Document! X 2011 by Innovasys