Class ByteArrayExtensions
- Namespace
- Cuemon.Extensions.Xml
- Assembly
- Cuemon.Extensions.Xml.dll
Extension methods for the byte[].
public static class ByteArrayExtensions
- Inheritance
-
ByteArrayExtensions
Examples
The following example demonstrates how to convert a byte array to an XmlReader using the ByteArrayExtensions class.
using System;
using System.Text;
using System.Xml;
using Cuemon.Extensions.Xml;
namespace MyApp.Examples;
public class ByteArrayExtensionsExample
{
public void Demonstrate()
{
byte[] xmlData = Encoding.UTF8.GetBytes("<root><item>Value</item></root>");
// Convert the byte array to an XmlReader
using (XmlReader reader = xmlData.ToXmlReader())
{
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element)
{
Console.WriteLine(reader.Name);
}}}}
}
Methods
ToXmlReader(byte[], Action<XmlReaderSettings>)
Converts the given value to an XmlReader.
public static XmlReader ToXmlReader(this byte[] value, Action<XmlReaderSettings> setup = null)
Parameters
valuebyte[]The byte[] to extend.
setupAction<XmlReaderSettings>The XmlReaderSettings which may be configured.