tags:

views:

32

answers:

2

I have to declare n = 01.

Nut whenever i try its getting changed as 1.

Wat should i Do ?

A: 

01 = 1, are you wanting a string "01" ?

John Boker
N its a Integer value
Harish
well if n is an integer 1 is the correct value. you want to use a string formatting function to display it differently
John Boker
you can use n.ToString().PadLeft(2, "0")
John Boker
@ Harish You can't do it. If you are doing some calculation then 0 in 01 anyway does not have any value and you should not be worried about it. if for some reason you need to store it as "01" then you got to change the data type to string.
Pradeep
+2  A: 

If this is just for display purposes then I would use the .ToString("0#"), unless you really need to do calculations based on two significant figures.

For index As Integer = 1 To 100
  Console.WriteLine(index.ToString("0#"))
Next

Gives you 01 02 . . 100

Dien