Table of Contents

ByteArrayExtensions Class

Definition

Namespace
Cuemon.Extensions.Xml
Assemblies
Cuemon.Extensions.Xml.dll
Source
src/Cuemon.Extensions.Xml/ByteArrayExtensions.cs

Extension methods for the byte array.

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

Name Description
ToXmlReader(byte[], Action<XmlReaderSettings>)

Converts the given value to an XmlReader.