概述
/// <summary>
/// 对转义字符进行处理
/// 左尖括号: < <
/// 右尖括号: > >
/// 单引号 : ' '
/// 双引号 : " "
/// (shift+7):& &
/// </summary>
public class TransferredMeaning
{
static public string Transferred(string Meaning)
{
//普通字符变换成转义字符
Meaning = Meaning.Replace("&", "&");
Meaning = Meaning.Replace("<", "<");
Meaning = Meaning.Replace(">", ">");
Meaning = Meaning.Replace("'", "'");
Meaning = Meaning.Replace(""", """);
return Meaning;
}
static public string UnTransferred(string Meaning)
{
//转义字符变换成普通字符
Meaning = Meaning.Replace("<", "<");
Meaning = Meaning.Replace(">", ">");
Meaning = Meaning.Replace("'", "'");
Meaning = Meaning.Replace(""",""");
Meaning = Meaning.Replace("&","&");
return Meaning;
}
最后
以上就是整齐故事为你收集整理的C#特殊字符转义的全部内容,希望文章能够帮你解决C#特殊字符转义所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复