Using the literal '@' with a string variable

后端 未结 6 761
Happy的楠姐
Happy的楠姐 2020-12-17 01:42

I have a helper class pulling a string from an XML file. That string is a file path (so it has backslashes in it). I need to use that string as it is... How can I use it lik

6条回答
  •  执笔经年
    2020-12-17 02:09

    I'm not sure if I understand. In your example: if helper.getFilePath() returns "c:\somepath\file.txt", there will be no problem, since the @ is only needed if you are explicitely specifying a string with "".

    When Functions talk to each other, you will always get the literal path. If the XML contains c:\somepath\file.txt and your function returns c:\somepath\file.txt, then string filePath will also contain c:\somepath\file.txt as a valid path.

提交回复
热议问题