locked
Cell format RRS feed

  • Question

  • User-1188570427 posted

    I am trying to read in my cell format from the database, but how would I place it into here?

    decimal value = 123.456m;
    
    Console.WriteLine("Your account balance is {0:C2}.", value);

    I want to read in "C2" from the database.

    I tried this:

    Console.WriteLine("Your account balance is {0:{1}}.", value, cellFormat);Error CA2241 Provide correct arguments to formatting methods 


    Error CA2241 Provide correct arguments to formatting methods 

    Monday, May 21, 2018 8:04 PM

Answers

  • User-1716253493 posted
    Console.WriteLine("Your account balance is {0:" + cellFormat + "}.", value);
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, May 21, 2018 9:19 PM

All replies

  • User475983607 posted

    Obviously, the syntax is incorrect.  You'll need to build a custom formatter according to your specification.   

    Monday, May 21, 2018 8:22 PM
  • User-1716253493 posted
    Console.WriteLine("Your account balance is {0:" + cellFormat + "}.", value);
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, May 21, 2018 9:19 PM
  • User-1188570427 posted

    Console.WriteLine("Your account balance is {0:" + cellFormat + "}.", value);

    Appears EXACTLY what I needed!

    Thank you. Works so far. I'll enter a new post if need be.

    Tuesday, May 22, 2018 2:03 PM