In C#, is there a way to convert an int value to a hex value without using the .ToString(“X”) method?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Your question is plain wrong (no offense intended). A number has one single value. Hex, Decimal, Binary, Octal, etc. are just different representations of one same integral number.
Int32is agnostic when it comes to what representation you choose to write it with.So when you ask:
you are asking something thast doesn’t make sense. A valid question would be:
is there anyway to write a integer in hexadecimal representation that doesn't involve using .ToString("X")?The answer is not really. Someway or the other (directly or not by you),
.ToString("X")or some other flavor ofToString()will be called to correctly format the string representing the value.And when you think of hexadecimal as a respresentation (a formatted string) of a given number, then
.ToString()does make sense.