Tomtom
Tomtom

Reputation: 9394

Read Resources without \r and \n

In a Resource-File in my WPF-Application I have a longer SQL-Statement for the creation of a Database while runtime. If I try to read the statement with string command = DataResources.CreateDbCommand I can get it, but there are several \r and \n in the command and I can not execute it.

How can I read a string from my resource-file without \r and \n?

Upvotes: 0

Views: 457

Answers (1)

Uzair Ahmed Siddiqui
Uzair Ahmed Siddiqui

Reputation: 364

If the \r \n are end or beginning you can just trim them with

command = command.Trim();

or you can remove them from anywhere in the string before executing the command

command = command.Replace("\r\n", " "); //replace with a space character
command = command.Replace("\r\n", ""); //remove them without adding anything 

Upvotes: 1

Related Questions