0

How do I convert this from VB.Net to c#?

Dim dd As String = Hex(ExpiryDate.Value.Day).PadLeft(4, "0")

I tried a conversion tool (It uses the mono project source code they say) http://www.developerfusion.com/tools/convert/vb-to-csharp/

and it came up with this but c# does not like it. - the code that is.

string dd = Conversion.Hex(ExpiryDate.Value.Day).PadLeft(4, "0");

This is the error:-

The name 'Conversion' does not exist in the current context
John Saunders
  • 160,644
  • 26
  • 247
  • 397
Gopher2011
  • 169
  • 1
  • 6
  • 16
  • 2
    Try this: http://stackoverflow.com/questions/74148/how-to-convert-numbers-between-hex-and-decimal-in-c – Nasir Jun 27 '11 at 16:05
  • It's sometimes better to just ask (but search first!) for what you are looking for, than by looking for some means to turn A into B in hopes of finding it ;-) –  Jun 27 '11 at 16:14
  • Thanks - I am new to this so forgive me if I seem a bit confused! Thanks for the link. – Gopher2011 Jun 29 '11 at 10:02

1 Answers1

6

This might be what you want:

string dd = String.Format("{0:x4}", ExpiryDate.Value.Day);
bbarnickel
  • 76
  • 2