Questions tagged [verbatim-string]

C# supports two forms of string literals: regular string literals and verbatim string literals. A verbatim string literal consists of an @ character followed by a double-quote character, zero or more characters, and a closing double-quote character

In a verbatim string literal, the characters between the delimiters are interpreted verbatim, the only exception being a quote-escape-sequence. In particular, simple escape sequences and hexadecimal and Unicode escape sequences are not processed in verbatim string literals. A verbatim string literal may span multiple lines.

57 questions
0
votes
1 answer

C# verbatim string insert to Acrobat Javascript

I have a syntax error and i can't solve it at the moment. Task: C# app with Acrobat JS Invoke... I pass this as a string command: acrofields.ExecuteThisJavascript(@"this.getField(""TM"").value = """ + TM_Textbox.Text + @""";"); I use verbatim…
Viktor
  • 1
  • 1
0
votes
2 answers

Make all Strings in class or namespace Verbatim String literals

Is it possible in .NET to make all strings within a class, namespace, file, etc. Verbatim String Literals. There are always a file or two that simply need tons of escaping, where it would be nice to have all strings be considered Verbatim String…
abc123
  • 17,855
  • 7
  • 52
  • 82
0
votes
2 answers

Escaping command line arguments in C# for Urls and Local and Network Paths

How do I provide an input string with automatic escaping to a console application? I mean inside my code, I can do public static void main(string[] args) { string myURL; myFolder = @"C:\temp\january\"; //just for testing myFolder…
FMFF
  • 1,652
  • 4
  • 32
  • 62
0
votes
1 answer

how to write this in Verbatim literal

I have an audio file name with spaces String filename = @"c:\users\me\desktop\this is audio.mp3"; say i want to open this file through cmd using external process,to open it i need the path to be like this : c:\users\me\desktop\"this is audio.mp3"…
Howa
  • 60
  • 7
-1
votes
1 answer

How do you put quotes around variables when using complex commands and C# interpolation?

I am trying to perform a Robocopy of a file. The command I'm using (below) works when the "filename" variable does not contain spaces. How can I write this command to ignore spaces in this variable? System.Diagnostics.Process.Start("robocopy.exe", …
dguth8
  • 29
  • 1
  • 5
-2
votes
1 answer

Verbatim string c# "'a\\\' b'"

I have string 'a\\\' b', i need make algorithm which will convert this string to string 'a' b' 'a\\\' b' = > 'a\\' b' => 'a\' b' = > 'a' b' How i can make it? Maybe c# have a method which can check , is char contains verbatim symbol or not?
-2
votes
1 answer

Verbatim string replace

var a = "asdfgh\r"; Console.WriteLine(a.Contains(@"\r")); var b = a.Replace(@"\r","").Replace(@"\n",""); var c = a.Replace("\r","").Replace("\n",""); Console.WriteLine(a); Console.WriteLine(b); Console.WriteLine(c); "b"…
tknkrtl
  • 87
  • 6
-2
votes
1 answer

How do I convert a string to a verbatim string using its identifier

For one method I have the parameters take a string, but I need that string to become a verbatim string once in the method. Here is an example of what I mean. //the string I have string test = "c:\\documents\\testfile\\test.txt" //the string I…
ykk123
  • 1
  • 1
-2
votes
1 answer

How I can escape a double quote in a verbatim string that contains variables

I have verbatim string that have some variables contacanete with, my problem I always get this error from the compiler: ; expected So how I can escape it properly? int teacherId = sqlStatus = (int)sqlCmd.LastInsertedId; sqlCmd.CommandText =…
H Aßdøµ
  • 2,925
  • 4
  • 26
  • 37
-2
votes
1 answer

Cannot remove double slashes from file path

I have a sub that is supposed to play a music file. I can locate MyDocuments easily. I can even use Path.Combine to concatenate the rest of the string. The full path should look something like this: ......Documents\JukeBox\MichaelJackson\01.wav But…
Beginner
  • 129
  • 10
-2
votes
2 answers

Why does attempting to verbatimize this string fail?

I have this substring I want to strip out of a string: Realizing it was full of funkiness, I thought…
B. Clay Shannon-B. Crow Raven
  • 8,547
  • 144
  • 472
  • 862
-2
votes
2 answers

Why C# requires two double-quotes to print " in case of verbatim string?

If I store a verbatim string, string s=@""Hello""; it should hypothetically parse the string and print "Hello" (taking the " character as a part of the string) but in actual practice it fails and instead string s=@"""Hello"""; displays the desired…
CᴴᴀZ
  • 521
  • 7
  • 20
1 2 3
4