why does character such as “” error in c# [duplicate]










-1
















This question already has an answer here:



  • How do I write the escape char '' to code

    6 answers



I have a textbox that has a value depends on the Path of the file after dragging the folder. the return value of dragged folder is "C:Program Files".
and I want to add the char "" on the textbox, but if I add that character, there is an error such as red line below my code, the example of a red line is when you misspelled a word in a document.



code:



txtResult.Text + "" + textFile + ".txt"



Question:



what is the main reason that this string value does have an error?










share|improve this question













marked as duplicate by mjwills, Tetsuya Yamamoto, D-Shih, Community Nov 12 '18 at 3:13


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






















    -1
















    This question already has an answer here:



    • How do I write the escape char '' to code

      6 answers



    I have a textbox that has a value depends on the Path of the file after dragging the folder. the return value of dragged folder is "C:Program Files".
    and I want to add the char "" on the textbox, but if I add that character, there is an error such as red line below my code, the example of a red line is when you misspelled a word in a document.



    code:



    txtResult.Text + "" + textFile + ".txt"



    Question:



    what is the main reason that this string value does have an error?










    share|improve this question













    marked as duplicate by mjwills, Tetsuya Yamamoto, D-Shih, Community Nov 12 '18 at 3:13


    This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.




















      -1












      -1








      -1









      This question already has an answer here:



      • How do I write the escape char '' to code

        6 answers



      I have a textbox that has a value depends on the Path of the file after dragging the folder. the return value of dragged folder is "C:Program Files".
      and I want to add the char "" on the textbox, but if I add that character, there is an error such as red line below my code, the example of a red line is when you misspelled a word in a document.



      code:



      txtResult.Text + "" + textFile + ".txt"



      Question:



      what is the main reason that this string value does have an error?










      share|improve this question















      This question already has an answer here:



      • How do I write the escape char '' to code

        6 answers



      I have a textbox that has a value depends on the Path of the file after dragging the folder. the return value of dragged folder is "C:Program Files".
      and I want to add the char "" on the textbox, but if I add that character, there is an error such as red line below my code, the example of a red line is when you misspelled a word in a document.



      code:



      txtResult.Text + "" + textFile + ".txt"



      Question:



      what is the main reason that this string value does have an error?





      This question already has an answer here:



      • How do I write the escape char '' to code

        6 answers







      c#






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 12 '18 at 2:58









      Alexis VillarAlexis Villar

      18211




      18211




      marked as duplicate by mjwills, Tetsuya Yamamoto, D-Shih, Community Nov 12 '18 at 3:13


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









      marked as duplicate by mjwills, Tetsuya Yamamoto, D-Shih, Community Nov 12 '18 at 3:13


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
























          1 Answer
          1






          active

          oldest

          votes


















          3














          When inside a string the backslash character '', it is interpreted as an escape character.



          In your case it's escaping the double quote, which is nesseccary when you want a double quote character inside a quoted string. However since you want the literal backslash, you should escape the backslash, which Means:



          Use "\".



          Now it will produce a single backslash.



          Edit:



          Another option is to use an @-quoted string, like this:



          @""


          Now you don't have to escape the character.






          share|improve this answer

























          • You may also use verbatim string: var path = @"C:Program Files";

            – vasily.sib
            Nov 12 '18 at 3:07











          • thank sir :) got it :)

            – Alexis Villar
            Nov 12 '18 at 3:13

















          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          3














          When inside a string the backslash character '', it is interpreted as an escape character.



          In your case it's escaping the double quote, which is nesseccary when you want a double quote character inside a quoted string. However since you want the literal backslash, you should escape the backslash, which Means:



          Use "\".



          Now it will produce a single backslash.



          Edit:



          Another option is to use an @-quoted string, like this:



          @""


          Now you don't have to escape the character.






          share|improve this answer

























          • You may also use verbatim string: var path = @"C:Program Files";

            – vasily.sib
            Nov 12 '18 at 3:07











          • thank sir :) got it :)

            – Alexis Villar
            Nov 12 '18 at 3:13















          3














          When inside a string the backslash character '', it is interpreted as an escape character.



          In your case it's escaping the double quote, which is nesseccary when you want a double quote character inside a quoted string. However since you want the literal backslash, you should escape the backslash, which Means:



          Use "\".



          Now it will produce a single backslash.



          Edit:



          Another option is to use an @-quoted string, like this:



          @""


          Now you don't have to escape the character.






          share|improve this answer

























          • You may also use verbatim string: var path = @"C:Program Files";

            – vasily.sib
            Nov 12 '18 at 3:07











          • thank sir :) got it :)

            – Alexis Villar
            Nov 12 '18 at 3:13













          3












          3








          3







          When inside a string the backslash character '', it is interpreted as an escape character.



          In your case it's escaping the double quote, which is nesseccary when you want a double quote character inside a quoted string. However since you want the literal backslash, you should escape the backslash, which Means:



          Use "\".



          Now it will produce a single backslash.



          Edit:



          Another option is to use an @-quoted string, like this:



          @""


          Now you don't have to escape the character.






          share|improve this answer















          When inside a string the backslash character '', it is interpreted as an escape character.



          In your case it's escaping the double quote, which is nesseccary when you want a double quote character inside a quoted string. However since you want the literal backslash, you should escape the backslash, which Means:



          Use "\".



          Now it will produce a single backslash.



          Edit:



          Another option is to use an @-quoted string, like this:



          @""


          Now you don't have to escape the character.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 12 '18 at 3:09

























          answered Nov 12 '18 at 3:05









          Poul BakPoul Bak

          5,48831233




          5,48831233












          • You may also use verbatim string: var path = @"C:Program Files";

            – vasily.sib
            Nov 12 '18 at 3:07











          • thank sir :) got it :)

            – Alexis Villar
            Nov 12 '18 at 3:13

















          • You may also use verbatim string: var path = @"C:Program Files";

            – vasily.sib
            Nov 12 '18 at 3:07











          • thank sir :) got it :)

            – Alexis Villar
            Nov 12 '18 at 3:13
















          You may also use verbatim string: var path = @"C:Program Files";

          – vasily.sib
          Nov 12 '18 at 3:07





          You may also use verbatim string: var path = @"C:Program Files";

          – vasily.sib
          Nov 12 '18 at 3:07













          thank sir :) got it :)

          – Alexis Villar
          Nov 12 '18 at 3:13





          thank sir :) got it :)

          – Alexis Villar
          Nov 12 '18 at 3:13





          Popular posts from this blog

          𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

          Edmonton

          Crossroads (UK TV series)