什么是在.NET做字符串模板的好方法? [英] What's a good way of doing string templating in .NET?

查看:159
本文介绍了什么是在.NET做字符串模板的好方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要发送电子邮件通知给用户,我需要让管理员提供邮件正文的模板(也可能是头,太)。

I need to send email notifications to users and I need to allow the admin to provide a template for the message body (and possibly headers, too).

我想类似的String.Format ,让我给命名的替换字符串,所以模板可以是这样的:

I'd like something like string.Format that allows me to give named replacement strings, so the template can look like this:

Dear {User},

Your job finished at {FinishTime} and your file is available for download at {FileURL}.

Regards,

-- 
{Signature}

什么是为我做的最简单的方法?

What's the simplest way for me to do that?

推荐答案

使用一个模板引擎。 StringTemplate的是其中之一,还有很多。

Use a templating engine. StringTemplate is one of those, and there are many.

这篇关于什么是在.NET做字符串模板的好方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆