Provides reading and writing to a stream of hexidecimal characters.
Syntax
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.NET | Copy 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