正解:
D_Val必须是int类型
D_Val_ = Microsoft.VisualBasic.Conversion.Hex(D_Val);
D_Val_ =(int.Parse(D_Val)).ToString("X");
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
c# vb.net
shareimprove this question
edited Jun 27 '11 at 16:07
John Saunders
155k2323 gold badges217217 silver badges375375 bronze badges
asked Jun 27 '11 at 16:00
Gopher2011
16911 gold badge55 silver badges1616 bronze badges
2
Try this: stackoverflow.com/questions/74148/… – 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 ;-) – user166390 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
add a comment
1 Answer
active oldest votes
5
This might be what you want:
string dd = String.Format("{0:x4}", ExpiryDate.Value.Day);
shareimprove this answer
answered Jun 27 '11 at 16:06
bbarnickel
6622 bronze badges
Dim read as String = Int("&H" & buffer.Substring(0, 4)).ToString.PadLeft(2, "0") – Gopher2011 Jun 29 '11 at 9:55
I worked it out! Sorry for the trouble! read = Convert.ToString(Convert.ToInt32(ReadString.Substring(00, 4), 16)); – Gopher2011 Jun 29 '11 at 10:23