如何在字符串中将\更改为\\ [英] how to change \ into \\ in a string

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

问题描述

你好

如何在C#中将字符串中的\更改为\\

例如:
"hello \ im \ nobody"必须为"hello \\ im \\ nobody"

Job

Hello

how can I change \ into \\ in a string in C#

example:
"hello\im\nobody" needs to be "hello\\im\\nobody"

Job

推荐答案

string str1=@"hello\im\nobody";
string str2 = str1.Replace(@"\", @"\\");
MessageBox.Show (str2);


这篇关于如何在字符串中将\更改为\\的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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