How can I remove the escape character?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

string str ="\"C:\Program Files\Internet Explorer\iexplore.exe\" -nohome"
How can I remove charcter to
string str = ="C:\Program Files\Internet Explorer\iexplore.exe -nohome"
 
string str ="\"C:\Program Files\Internet Explorer\iexplore.exe\" -nohome"
How can I remove charcter to
string str = ="C:\Program Files\Internet Explorer\iexplore.exe -nohome"

str = str.Replace("\"", string.Empty);
 
Steve said:
string str ="\"C:\Program Files\Internet Explorer\iexplore.exe\" -nohome"
How can I remove charcter to
string str = ="C:\Program Files\Internet Explorer\iexplore.exe -nohome"
I'm not entirely sure of what you are asking here, since in both
examples the escape character exists. If you mean how can you make the
string so that it "ignores" the escape character, you can define it like so:

string str = @"C:\Program Files\Internet Explorer\iexplore.exe -nohome";

The @ symbol forces the creation of a "literal string", in which escape
characters are not interpreted as such.

HTH...

Chris
 
str = str.Replace("\"", string.Empty); fixed my problem, thanks a lot.
I am interesting your solution "@", for I read document also mentioned @ can
remove the escape character.

this is my code
RegistryKey readiexplorer1 =
Registry.ClassesRoot.OpenSubKey(iexplorer_registry, true);
String default_iexplorer = (String)readiexplorer1.GetValue("");
string launch_iexplorer_path = default_iexplorer +
default_command_path;
RegistryKey readiexplorer2 =
Registry.ClassesRoot.OpenSubKey(launch_iexplorer_path, true);
string launch_iexplorer = (String)readiexplorer2.GetValue("");
I got launch_iexplorer ="\"C:\Program Files\Internet Explorer\iexplore.exe\"
-nohome"

How can I remove the escpe character based on @?
 
Steve said:
str = str.Replace("\"", string.Empty); fixed my problem, thanks a lot.
I am interesting your solution "@", for I read document also mentioned @ can
remove the escape character.

this is my code
RegistryKey readiexplorer1 =
Registry.ClassesRoot.OpenSubKey(iexplorer_registry, true);
String default_iexplorer = (String)readiexplorer1.GetValue("");
string launch_iexplorer_path = default_iexplorer +
default_command_path;
RegistryKey readiexplorer2 =
Registry.ClassesRoot.OpenSubKey(launch_iexplorer_path, true);
string launch_iexplorer = (String)readiexplorer2.GetValue("");
I got launch_iexplorer ="\"C:\Program Files\Internet Explorer\iexplore.exe\"
-nohome"

How can I remove the escpe character based on @?
Instead of casting to a "String", have you tried casting to a "string"?

Chris
 
It begs the question why you'd want to, surely the first expression is what
you'd want, i.e. with the double quotes in?
 
No.
Without double quote in, for I will split the string with .exe this will
cause \" in another dimension.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top