Class ArrayExtensions
- Namespace
- AetherUtils.Core.Extensions
- Assembly
- AetherUtils.Core.dll
Provides extension methods for manipulating Array objects.
public static class ArrayExtensions
- Inheritance
-
ArrayExtensions
- Inherited Members
Methods
FromPrintableString(string)
Convert a hexadecimal string representation of bytes into its equivalent byte array.
public static IEnumerable<byte> FromPrintableString(this string byteString)
Parameters
byteStringstring- The string containing the hexadecimal values.
This string can contain values seperated by '-' (
CE-B7-8D) or not (CEB78D).
Returns
- IEnumerable<byte>
- A byte array representing the hexadecimal string.
ToImage(byte[])
[UsedImplicitly]
public static Image ToImage(this byte[] bytes)
Parameters
Returns
Exceptions
- ArgumentNullException
- If
byteswasnull. - FormatException
- If
bytesdid not have a valid ImageFormat.
ToPrintableString(IEnumerable<byte>)
Convert the numeric value of each element of a specified array of bytes to
its equivalent hexadecimal string representation.
public static string ToPrintableString(this IEnumerable<byte> bytes)
Parameters
bytesIEnumerable<byte>- An IEnumerable<T> of bytes.
Returns
- string
- A string of hexadecimal pairs separated by hyphens, where each pair represents the corresponding element in value; for example, "7F-2C-4A-00".
Exceptions
- ArgumentNullException
- If
byteswasnull.
ToStringList<T>(T[], char, string, string)
Convert an array of values to a string using the specified prefix, delimiter, and optional suffix.
[UsedImplicitly]
public static string ToStringList<T>(this T[] values, char delimiter = ',', string prefix = "", string suffix = "")
Parameters
valuesT[]- The array of values to combine.
delimiterchar- The delimiter to separate the values with; default is
',' prefixstring- The prefix to add to the resulting string; default is an empty string.
suffixstring- The suffix to add to the resulting string; default is an empty string.
Returns
- string
- A string formatted with the
valuesseperated by thedelimiter.
Type Parameters
T- The type of objects contained within the array.
Examples
string[] values = ["val1", "val2", "val3"];
string str = values.ToStringList(',', "PRE(", ")");
returns: "PRE(val1,val2,val3)"
Exceptions
- ArgumentNullException
- If
values,prefixwasnull.