Class SHFormat
- Namespace
- SunamoStringFormat
- Assembly
- SunamoStringFormat.dll
Provides multiple string formatting methods that support custom bracket characters and error handling.
public class SHFormat
- Inheritance
-
SHFormat
- Inherited Members
- Extension Methods
Methods
Format(string, string, string, params object[])
Formats a template string using Format2(string, params object[]), then replaces standard curly braces with custom separators. Cannot be used when template contains unfinished curly braces.
public static string Format(string template, string leftSeparator, string rightSeparator, params object[] args)
Parameters
templatestringThe format template string.
leftSeparatorstringThe custom left separator to replace '{' with.
rightSeparatorstringThe custom right separator to replace '}' with.
argsobject[]The format arguments.
Returns
- string
The formatted string with custom separators.
Format2(string, params object[])
Formats a template string using Format(string, params object[]) with error checking. Does not allow formatting when template contains unfinished curly braces without indexed placeholders.
public static string Format2(string template, params object[] args)
Parameters
Returns
- string
The formatted string, or the original template if formatting is not applicable.
Format3(string, params object[])
Formats a template string by manually replacing each {i} placeholder with the corresponding argument. Supports multiline templates and can be used with wildcard characters.
public static string Format3(string template, params object[] args)
Parameters
templatestringThe format template string containing {0}, {1}, etc. placeholders.
argsobject[]The format arguments to substitute into the template.
Returns
- string
The formatted string with all placeholders replaced.
Format34(string, params object[])
Formats a template string by attempting both Format4(string, params object[]) and Format3(string, params object[]), suppressing exceptions. Supports multiline templates.
public static string Format34(string template, params object[] args)
Parameters
Returns
- string
The formatted string, or the original template if both formatting attempts fail.
Format4(string, params object[])
Formats a template string using Format(string, params object[]) without error checking. Useful for special string formatting patterns like {0:X2}.
public static string Format4(string template, params object[] args)
Parameters
Returns
- string
The formatted string.
Format5(string, string, string, params object[])
Formats a template string by manually replacing custom-bracketed placeholders with the corresponding arguments. Supports multiline templates and custom left/right separators instead of curly braces.
public static string Format5(string template, string leftSeparator, string rightSeparator, params object[] args)
Parameters
templatestringThe format template string.
leftSeparatorstringThe custom left separator used in placeholders.
rightSeparatorstringThe custom right separator used in placeholders.
argsobject[]The format arguments to substitute into the template.
Returns
- string
The formatted string with all custom placeholders replaced.