Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

How to format a decimal number string with zero padding?

tostring decimal zero padding netduino

Best Answer RobB916, 31 January 2014 - 05:03 PM

number.ToString(String.Format("000", number)); ? Although you said "...number.ToString("000") as you would with VS C#..." Your line was missing a little. Dont know if that was a mistake or just shorthand.

Go to the full post


  • Please log in to reply
3 replies to this topic

#1 yonggon

yonggon

    New Member

  • Members
  • Pip
  • 2 posts
  • LocationWisconsin

Posted 24 January 2014 - 03:05 PM

I want to make a three digit string with an integer. So 31 becomes 031 and 9 becomes 009.

 

I tried number.ToString("D3") or number.ToString("000") as you would with VS C#, but these does not work.

 

I have been searching all over and have been struggling with this but cannot find a solution other than writing a code strip for it.

 

Help!

 



#2 RobB916

RobB916

    New Member

  • Members
  • Pip
  • 1 posts

Posted 31 January 2014 - 05:03 PM   Best Answer

number.ToString(String.Format("000", number)); ? Although you said "...number.ToString("000") as you would with VS C#..." Your line was missing a little. Dont know if that was a mistake or just shorthand.



#3 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 31 January 2014 - 10:50 PM

Hi yonggon, If you want to try out the latest .NET Micro Framework beta firmware, ToString("D#") support has been added in NETMF v4.3. Chris

#4 yonggon

yonggon

    New Member

  • Members
  • Pip
  • 2 posts
  • LocationWisconsin

Posted 03 February 2014 - 06:54 AM

Thank you RobB916 and Chris!







Also tagged with one or more of these keywords: tostring, decimal, zero padding, netduino

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.