470,849 Members | 1,033 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,849 developers. It's quick & easy.

C# equivalent of Chr()

2
I am trying to change some code from VB to C#.

I have a variable called pstrHex with a value of "49799879A7E109F3B4BB4224257E50B5"

in VB, the following code:

HexToString = HexToString & Chr("&h" & Mid(pstrHex, llngIndex, 2))
Response.Write(HexToString)

gives me the value:

Iyy B$%~P

So far in C# I have:

HexToString = HexToString + ("&h" + pstrHex.Substring(llngIndex, 2));

I am not sure how to translate the Chr() part into C#. Any help would be appreciated.
Apr 26 '06 #1
1 3924
Try this:

public int HexToInt(string hexString)
{
// hexString is the "&h" + pstrHex.Substring(llngIndex, 2)
// you can remove the "&h" prefix since that is a strictly VB notation...
return int.Parse(hexString,
System.Globalization.NumberStyles.HexNumber, null);
}
Apr 27 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

6 posts views Thread by Vasanth | last post: by
5 posts views Thread by Brett Hargreaves | last post: by
9 posts views Thread by Alan Silver | last post: by
reply views Thread by sakina | last post: by
4 posts views Thread by Putty | last post: by
reply views Thread by basudahal | last post: by
8 posts views Thread by Lauren Quantrell | last post: by
4 posts views Thread by David Griffiths | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.