locked
How to Wrap text in double quote for specific scenario RRS feed

  • Question

  • i know how to put text in double quote. this way people put text in double quote. 

    string s = @"""my string""";

    My scenario is bit different. see how my text look like which i need to wrap in double quote.

    string formula = Consensus Model~Total Operating Expenses-GAAP~CL~4Q 2014 + Consensus Model~Total Operating Expenses-GAAP~CL~3Q 2014 + Consensus Model~Total Operating Expenses-GAAP~CL~2Q 2014 + Consensus Model~Total Operating Expenses-GAAP~CL~1Q 2014
    
    formula = Consensus Model~Total Operating Expenses-GAAP~CL~4Q 2014 + Consensus Model~Total Operating Expenses-GAAP~CL~3Q 2014 + Consensus Model~Total Operating Expenses-GAAP~CL~2Q 2014 / Consensus Model~Total Operating Expenses-GAAP~CL~1Q 2014
    
    formula = Consensus Model~Total Operating Expenses-GAAP~CL~4Q 2014 * 5
    
    formula = (Consensus Model~Total Operating Expenses-GAAP~CL~4Q 2014 + Consensus Model~Total Operating Expenses-GAAP~CL~3Q 2014 + Consensus Model~Total Operating Expenses-GAAP~CL~2Q 2014 + Consensus Model~Total Operating Expenses-GAAP~CL~1Q 2014)
    
    formula = (Consensus Model~Total Operating Expenses-GAAP~CL~4Q 2014 + Consensus Model~Total Operating Expenses-GAAP~CL~3Q 2014 + Consensus Model~Total Operating Expenses-GAAP~CL~2Q 2014) / Consensus Model~Total Operating Expenses-GAAP~CL~1Q 2014

    basically at runtime i convert these text Consensus Model~Total Operating Expenses-GAAP~CL~4Q 2014 to excel cell address AA10 etc

    now i want to get a specific logic which will put the formula text in double quote. after putting it double quote text should look  like following example.

    string formula = "Consensus Model~Total Operating Expenses-GAAP~CL~4Q 2014" + "Consensus Model~Total Operating Expenses-GAAP~CL~3Q 2014" + "Consensus Model~Total Operating Expenses-GAAP~CL~2Q 2014" + "Consensus Model~Total Operating Expenses-GAAP~CL~1Q 2014"
    
    formula = "Consensus Model~Total Operating Expenses-GAAP~CL~4Q 2014" + "Consensus Model~Total Operating Expenses-GAAP~CL~3Q 2014" + "Consensus Model~Total Operating Expenses-GAAP~CL~2Q 2014" / "Consensus Model~Total Operating Expenses-GAAP~CL~1Q 2014"
    
    formula = "Consensus Model~Total Operating Expenses-GAAP~CL~4Q 2014" * 5
    
    formula = ("Consensus Model~Total Operating Expenses-GAAP~CL~4Q 2014" + "Consensus Model~Total Operating Expenses-GAAP~CL~3Q 2014" + "Consensus Model~Total Operating Expenses-GAAP~CL~2Q 2014" + "Consensus Model~Total Operating Expenses-GAAP~CL~1Q 2014")
    
    formula = ("Consensus Model~Total Operating Expenses-GAAP~CL~4Q 2014" + "Consensus Model~Total Operating Expenses-GAAP~CL~3Q 2014" + "Consensus Model~Total Operating Expenses-GAAP~CL~2Q 2014") / "Consensus Model~Total Operating Expenses-GAAP~CL~1Q 2014"
    please help me with c# logic how could i put my formula into double quote in this way.

    thanks

    Saturday, September 12, 2020 12:14 PM

All replies

  • There are lots and lots of ways to do this, but my favorite is using "character literals."

                // So this is your original string
                string s = @"My String";
                // Here you add the single character literal to each end of the string.
                // Any single character placed inside single quotes is a character literal 
                // in C/++/#
                s = '"' + s + '"';


    Before you can learn anything new you have to learn that there's stuff you don't know.

    • Marked as answer by Sudip_inn Sunday, September 13, 2020 10:09 AM
    • Unmarked as answer by Sudip_inn Wednesday, September 23, 2020 7:04 AM
    Saturday, September 12, 2020 3:46 PM
  • How to wrap the below text with in double quote?

    "Segment Details~Other~9999"-"Segment Details~Other,GP~9999"

    there is two part first part is in double quote and second part too now how could i store this text in variable where whole text would be inside double quote?

    thanks

    Tuesday, September 22, 2020 8:53 AM
  • How to wrap the below text with in double quote?

    "Segment Details~Other~9999"-"Segment Details~Other,GP~9999"

    there is two part first part is in double quote and second part too now how could i store this text in variable where whole text would be inside double quote?

    thanks


    // Using string concatentation or concat for short:
    '"' + @"Segment Details~Other~9999" + '"' + '-' + '"' + @"Segment Details~Other,GP~9999" + '"'


    Before you can learn anything new you have to learn that there's stuff you don't know.

    Tuesday, September 22, 2020 1:18 PM
  • This is coming from db. so i can not do it this way the way you put the whole text inside .

    "Segment Details~Other~9999"-"Segment Details~Other,GP~9999"

    Now i want to store this text into a string variable with double quote surrounded. how it would be possible ?

    still my question not clear then please aske me i will explain it again elaborately what i am looking for? thanks

    Tuesday, September 22, 2020 2:14 PM
  • Somebody else will have to help you.  This thread is ridiculous.  Either ask your whole question in the first place or don't waste everybody's time with your nonsense.

    Before you can learn anything new you have to learn that there's stuff you don't know.

    Tuesday, September 22, 2020 2:44 PM