String template class in C#

PHPz
Release: 2023-08-24 15:13:02
forward
1140 people have browsed it

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()
Copy after login

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 });
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template