如何在 C# 中解码 HTML 字符? [英] How can I decode HTML characters in C#?

查看:24
本文介绍了如何在 C# 中解码 HTML 字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有用 HTML 字符实体编码的电子邮件地址..NET 中是否有任何东西可以将它们转换为纯字符串?

I have email addresses encoded with HTML character entities. Is there anything in .NET that can convert them to plain strings?

推荐答案

您可以使用 HttpUtility.HtmlDecode

如果您使用 .NET 4.0+,您还可以使用 WebUtility.HtmlDecode 不需要额外的程序集引用,因为它在 System.Net 命名空间中可用.

If you are using .NET 4.0+ you can also use WebUtility.HtmlDecode which does not require an extra assembly reference as it is available in the System.Net namespace.

这篇关于如何在 C# 中解码 HTML 字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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