| NiceFormatterSample(String, Int32) Method |
Converts a string into a nicely formatted string whre leading and trailing characters of a maximum length
are displayed, but excess middle charactes are replaced with a count placeholder. It therefore displays a
sample of a string of arbitrary length. The middle truncation is skipped if it is less than 8 characters long.
Namespace: Orthogonal.Common.BasicAssembly: Orthogonal.Common.Basic (in Orthogonal.Common.Basic.dll) Version: 2024-04-15 18:00 GMT+10.f27da1471008deaf16b803c17e24a5955690aef1
Syntax public static string Sample(
this string value,
int sampleLength = 40
)
Parameters
- value String
- The value to nicely format as a sample.
- sampleLength Int32 (Optional)
- The length of the leading and trailing charcters to be shown as a sample of the string.
Default is 40.
Return Value
StringA nicely formatted sample of the input string.
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type
String. 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
const string Lorem = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";
string sample = Lorem.Sample(20);
Console.WriteLine(sample);
See Also