dynamic formatting using string.format RRS feed

  • Question

  • Hi,

    I have a different scenario in formatting string.

    The format value and format type are in database.

    So the code needs to format the value accordingly.

    Say, if it is currency value it has to the currency format.

    If it is number value it has to the number format.

    Here I have given the sample code.

    string strValue= "1234567";

    string strFormat="{0:c}";



    But the above code does not formatting...

    I hope you have solution for this.

    thanks in advance

    chandra babu

    Tuesday, November 7, 2006 11:22 PM

All replies

  • Hi Babu,


    You should pass the strong typed parameter as value.

    String.Format expects the typed parameter to apply the specied format string.

    Change your code as follow as,



    Wednesday, November 8, 2006 8:46 AM