 | NiceFormatter.Sample(Byte[], Int32) Method |
Converts a buffer into a nicely formatted string where leading and trailing bytes of a maximum length are
displayed, but excess middle bytes are replaced with a count placeholder. It therefore displays a sample
of a buffer of arbitrary length. The middle truncation is skipped if it is less than 8 bytes long.
Namespace: Orthogonal.Common.BasicAssembly: Orthogonal.Common.Basic (in Orthogonal.Common.Basic.dll) Version: 2025-03-15 14:42 GMT+11
Syntaxpublic static string Sample(
this byte[] buffer,
int sampleLength = 32
)
Parameters
- buffer Byte[]
- The buffer to nicely format as a sample.
- sampleLength Int32 (Optional)
- The length of the leading and trailing bytes to be shown as a sample of the buffer.
Return Value
StringA string representation sample of a buffer.
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type
Byte[]. When you use instance method syntax to call this method, omit the first parameter. For more information, see
Extension Methods (Visual Basic) or
Extension Methods (C# Programming Guide).
Exceptions
Example
var buff = new byte[1000];
string sample = buff.Sample(8);
Console.WriteLine(sample);
See Also