Table of Contents

Class Eradicate

Namespace
Cuemon
Assembly
Cuemon.Core.dll

Provides a set of static methods for eradicating different types of values or sequences of values.

public static class Eradicate
Inheritance
Eradicate

Examples

The following example demonstrates how to use Eradicate to clean up byte arrays by removing trailing zero bytes or specific trailing byte sequences.

using System;
using System.Text;

namespace Cuemon;

public class EradicateExample
{
    public void Demonstrate()
    {
        // Remove trailing zero bytes from a byte array
        byte[] dataWithZeros = { 1, 2, 3, 0, 0, 0 };
        byte[] cleaned = Eradicate.TrailingZeros(dataWithZeros);
        Console.WriteLine(BitConverter.ToString(cleaned)); // 01-02-03

        // Remove specific trailing byte sequence (e.g., CR/LF)
        byte[] dataWithCrLf = { 72, 101, 108, 108, 111, 13, 10, 13, 10 };
        byte[] stripped = Eradicate.TrailingBytes(dataWithCrLf, new byte[] { 13, 10 });
        Console.WriteLine(Encoding.UTF8.GetString(stripped)); // Hello
    }
}

Methods

TrailingBytes(byte[], byte[])

Eradicates trailing byte information (if any) from the specified set of bytes.

public static byte[] TrailingBytes(byte[] bytes, byte[] trailingBytes)

Parameters

bytes byte[]

The byte[] to process.

trailingBytes byte[]

The byte[] to form the trailing bytes.

Returns

byte[]

A byte[] without trailingBytes.

Exceptions

ArgumentNullException

bytes cannot be null - or - trailingBytes cannot be null.

ArgumentOutOfRangeException

bytes must have a length larger than 1.

TrailingZeros(byte[])

Eradicates trailing zero information (if any) from the specified set of bytes.

public static byte[] TrailingZeros(byte[] bytes)

Parameters

bytes byte[]

The byte[] to process.

Returns

byte[]

A byte[] without trailing zeros.

Exceptions

ArgumentNullException

bytes cannot be null.

ArgumentOutOfRangeException

bytes must have a length larger than 1.

See Also