This question already has answers here:
Replace "\\" with "\" in a string in C#
(9 answers)
Closed 5 years ago.
I want "PRR\17-18\12" to be PRR\17-18\12
I Have tried below ways but its not working
DepositCode.Replace("\\", "\");
DepositCode.Replace(#"\", #"\");
someone please help
Do you want something like that;
DepositCode= DepositCode.Replace(#"\\", #"\");
Related
This question already has answers here:
string.Replace (or other string modification) not working
(4 answers)
Closed last year.
I have a problem in c# with replace in a string with space at the end.
"ERROR.1️.1.1094".Replace("ERROR.1.", "")
Expected value is 1.1094 but it's not working.
Can anybody help me?
Please try the following
"ERROR 1️ 1.1094".Replace("ERROR 1 ", string.Empty)
This question already has answers here:
Removing carriage return and linefeed from the end of a string in C#
(13 answers)
Closed 2 years ago.
Hi i have strange problem. Here is my code:
string tmp = "20_29\u0013";
How can I get rid of that "\u0013"?
Normally I will do it with substring or something but I have some issues with that character ---> \
Could someone help me?
You can use tmp.TrimEnd('\u0013') if it is single char or tmp.Replace("\\u0013", string.Empty) if it is sequence of chars to get "20_29" part:
This question already has answers here:
How to remove empty lines from a formatted string
(11 answers)
Closed 6 years ago.
How can I remove empty line from a string for example:
Turn this:
to This:
I used this code text.Replace("\n",""); but it turns it to:
testtesttes
You should replace two newline characters(if any). Following code will work on Unix as well as non unix platforms.
var stringWithoutEmptyLines = yourString.Replace(Environment.NewLine + Environment.NewLine, Environment.NewLine);
string data = stringData.Replace("\r\n\r\n", "\r\n");
This question already has answers here:
How do I write a backslash (\) in a string?
(6 answers)
Closed 7 years ago.
I am trying to do a string replace for website names. Here is the code:
string output = input.Replace("C:\Design\Website\", "Someting");
TextBox.Text = osc.output;
The code is incorrect as there is an issue \ with these marks. How can I fix my code?
You need to escape the \:
Either:
"C:\\Design\\Website\\"
Or:
#"C:\Design\Website\"
This question already has answers here:
What's the # in front of a string in C#?
(9 answers)
Closed 8 years ago.
What does "#" mean before a string?
I saw this notation with paths:
string myfolder = #"C:\Users\";
But also with normal strings.
It means it's a literal string, so won't treat \ as an escape character, for example. This page should help you understand it better.