在 C# 中,如何用 & 替换\u0026? [英] In C#, how can I replace\u0026 with &?

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

问题描述

我在我的 C# 代码中得到一个来自一些 javascript 序列化的字符串,我看到一堆这样的字符串:

I am getting a string in my C# code that comes from some javascript serialization and I see a bunch of strings like this:

  Peanut Butter \u0026 Jelly

我尝试这样做:

  string results  = resultFromJsonSerialization();
  results = results.Replace("\u0026", "&");
  return results;

我希望它变成:

 Peanut Butter & Jelly

但它似乎没有进行替换.在 C# 中进行此替换的正确方法是什么?

but it doesn't seem to do the replace. What is the correct way to do this replacement in C#?

推荐答案

将其标记为文字

results.Replace(@"\u0026", "&");

这篇关于在 C# 中,如何用 & 替换\u0026?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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