To give some context, I have a spreadsheet that prices financial derivatives by running a Monte Carlo simulation on an arbitrary user input payoff function that is defined by a string (a Python lambda expression). This is passed from Excel to my C# library using Excel DNA. The string is then executed as Python code using IronPython.
I've never had any problems with this but today I wanted to pass some more sophisticated Python code from Excel to C# that requires "\r\n" i.e. force a new line. The problem I am encountering is that when I try and input a backslash in Excel, when the string "arrives" in C# it has been modified as follows:
\ gets modified to "\"
and
"\" gets modified to "\"\\""
I think this is the source of the problem I am encountering (ultimately I get the following exception):
unexpected token '\'
Any help or tips would be really appreciated!
Thanks.