问题
I'm working on exam in which when the student asked to something like (declare if statement) he will answer in Rich text box.
the question is: I want to search for the input of the student in that box, and therefore, I must declare a string that contains the code (as string) something like that:
string check = " string stat = "new";
if (stat == "new")
{
Console.WriteLine(stat);
}
";
However, the problem is that, the escape characters and the other preserved voids such as (if).
Briefly: I want to create string that contains a code.
NOTE: I have tried the @ and putting \ before escape characters, but it didn't work.
Thanks
回答1:
This is called the escape sequence and looks like \ concatenated with " (or another symbol):
string check = " ... \" ...";
Where \" means "
来源:https://stackoverflow.com/questions/49394014/how-to-write-a-code-as-string-variable-c