Go4Expert (http://www.go4expert.com/)
-   C# (http://www.go4expert.com/forums/c-sharp/)
-   -   Passing numbers with leading zeros (http://www.go4expert.com/forums/passing-leading-zeros-t21289/)

reppig 11Mar2010 07:40

Passing numbers with leading zeros
I am new to C# having inherited a program that controls an antenna rotor through an RS-232 port. The command which must be sent to the rotor controller is in the form

"W aaa eee" where W is the command, aaa is a 3 digit the azimuth and eee is a 3 digit elevation for the antenna. So, aaa & eee can be any number between 0 and 360.

My problem is - if I want to move to 10, I need to type in 010 and pass 010 over RS232 port. Right now the program drops the leading zero/zeros.

How do I send a number with the leading zeros?? Any help would be wonderful. Many thanks in advance.

Judy Garland 12Mar2010 10:37

Re: Passing numbers with leading zeros
You can use the custom format string. Please try this:

int a = 10;

then you will get "010".

Hope it helps:D

Judy Garland
Free Live Chat Software

reppig 13Mar2010 06:36

Re: Passing numbers with leading zeros
Thank you very much. I thought it would be something easy to do.

All times are GMT +5.5. The time now is 18:53.