This mostly comes up while trying to debug F# code in the Visual Studio debugger, which expects C# syntax:
The debugger does not recognize F# expressions. To enter an expression in a debugger window or a dialog box during F# debugging, you must translate the expression into C# syntax. When you translate an F# expression into C#, make sure to remember that C# uses == as the comparison operator for equality and that F# uses a single =.
(from http://msdn.microsoft.com/en-us/library/vstudio/ee843932.aspx )
The problem is that I have variables and functions that contain single quote characters, like path'
, but single quotes seem not to be valid in names in C#, so entering path'
in the debugger window just says Newline expected in constant
or words to that effect, because it thinks I am starting a character literal. Even right-clicking on it and adding a watch via the contextual menu gives a similar error.
How can I translate F# names containing single quotes into C# syntax, so that I can inspect them from the debugger or refer to them from C# code?
I do not think there is a way to do this - so the best option is probably to rename the variable path'
to some other name that is a valid C# identifier like pathAux
.
Although F# is more flexible with naming (and allows things like path'
or even ``whatever !``
), it is probably a good idea to use C#-compatible identifier names most of the times, because it will make the code readable to a wider audience - such as C# developers.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.