Home > Article > Backend Development > String template class in C#
The StringTemplate class is used to parse the format string to make it compatible with String.Format. StringTemplate class belongs to NString library, which has extension methods. These methods make string manipulation easy to use, e.g.
IsNullOrEmpty() IsNullOrWhiteSpace() Join() Truncate() Left() Right() Capitalize()
StringTemplate.Format is better than String.Format because it is more readable and less error-prone.
The order of values can be easily formatted. The values are formatted similarly to String.Format, but using named placeholders instead of numbered placeholders.
The following is an example −
string str = StringTemplate.Format("{ExamName} will held on {ExamDate:D}", new { p.ExamName, p.ExamDate });
The above is the detailed content of String template class in C#. For more information, please follow other related articles on the PHP Chinese website!