Hello, how to write quotes ("") to a file (C #)?

Closed due to the fact that the essence of the question is incomprehensible by the participants Igor , Mark Shevchenko , Kromster , 0xdb , cheops 15 Feb '18 at 5:10 .

Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • one
    Suppose so streamWriter.Write("\""); - nick_n_a
  • five
    Open file for writing. Write down. Close the file. - tym32167
  • one
    @nick_n_a is formally an example of writing to a stream, not to a file. For me, there is not enough information in the question. What you tried, what doesn't work, as they write to the file - none of this is clear. - tym32167
  • one
    I assume that the author does not know what screening is. I showed screening \" as the most common question. - nick_n_a
  • one
    Well, then File.WriteAllText ("s.txt", "\" "); - writes quotes to the file :) - Alexander

1 answer 1

In order to display quotes, you need to use экранированием символов .

Inside lines, characters are escaped using the '\' character.

Let s be the string to be written to the file.

 string s="На вывеске магазина красовалась надпись \"Посторонним вход воспрещён\""; 

The value of the variable s after code execution:

На вывеске магазина красовалась надпись "Посторонним вход воспрещён"

I think it is clear how to use character shielding.

If something is not clear, I will describe it in more detail.