Number Format

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mr Nobody

    Number Format

    Hi all,

    Are there any numeric functions i can use to prepend '0' to all numbers less
    than 10?

    Currently i am doing this: int Val = (Convert.ToInt3 2(strTimeValue) < 10 ?
    String.Concat(" 0", strTimeValue) : strTimeValue);

    But wonder if the is some number format function that will do this for me?

    Any help appreciated!!!


  • Munna

    #2
    Re: Number Format

    Hi,,

    System.Math has few of the function that work on decimal or double
    i.e. Math.Truncate, Math.Ceiling() and Math.Floor() but those all work
    on double or decimal...
    what you are asking is operate on integer portion... well i guess you
    can write a function of your own

    Best of luck

    Munna




    Comment

    • =?Utf-8?B?TWlrZSBDb2xsaW5z?=

      #3
      RE: Number Format

      Try this:

      int num = 9;
      Response.Write( String.Format(" {0:00#}", num));


      "Mr Nobody" wrote:
      Hi all,
      >
      Are there any numeric functions i can use to prepend '0' to all numbers less
      than 10?
      >
      Currently i am doing this: int Val = (Convert.ToInt3 2(strTimeValue) < 10 ?
      String.Concat(" 0", strTimeValue) : strTimeValue);
      >
      But wonder if the is some number format function that will do this for me?
      >
      Any help appreciated!!!
      >
      >
      >

      Comment

      • John Rivers

        #4
        Re: Number Format

        variable.ToStri ng("00")

        RTFM

        Comment

        Working...