如何使用它里面引号字符串? [英] How to use a string with quotation marks inside it?

查看:117
本文介绍了如何使用它里面引号字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下字符串,我想执行一个过程:



Rundll32的Printui.dll,PrintUIEntry / IA / K / q / MSHARP MX-5500N PS/ H的Windows NT 86/ v 3 /˚Fsn0hwenu.inf



不过,鉴于引号的存在,我不能在C#中插入此字符串,使之编译,将所有的原有结构。我应该如何解决这个问题?因为有在字符串中引号这是一个有点棘手。


解决方案

 字符串不管= Rundll32的Printui.dll,PrintUIEntry / IA / K / q / M \SHARP MX-5500N PS\/ h的\的Windows NT x86\/ v 3 /˚Fsn0hwenu.inf 

 字符串无论= @Rundll32的Printui.dll,PrintUIEntry / IA / K / q / M,SHARP MX-5500N PS/小时,Windows NT的86/ v 3 /˚Fsn0hwenu.inf ; 


I have the following string, which I want to execute as a process:

Rundll32 Printui.dll,PrintUIEntry /ia /K /q /m "SHARP MX-5500N PS" /h "Windows NT x86" /v 3 /f sn0hwenu.inf

However, given the presence of quotation marks, I can't insert this string in C# to make it compile, keeping all of the original structure. How should I fix this? It's a little tricky as there are quotation marks within the string.

解决方案

string whatever = "Rundll32 Printui.dll,PrintUIEntry /ia /K /q /m \"SHARP MX-5500N PS\" /h \"Windows NT x86\" /v 3 /f sn0hwenu.inf";

or

string whatever = @"Rundll32 Printui.dll,PrintUIEntry /ia /K /q /m ""SHARP MX-5500N PS"" /h ""Windows NT x86"" /v 3 /f sn0hwenu.inf";

这篇关于如何使用它里面引号字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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