How to Convert Hex String to Hex Number [duplicate] - c#

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
How do I convert hex string into signed integer?
example:"3A" convert to 0x3A,thanks a lot!

Convert.ToInt32("3A", 16)

int.Parse("3A",NumberStyles.HexNumber)
or
long.Parse("3A",NumberStyles.HexNumber)
etc...

Related

How to decoding UTF8 encoded value in C#? [duplicate]

This question already has answers here:
How do I decode a URL parameter using C#?
(5 answers)
Closed 7 years ago.
Cookie value stored in UTF8 Encoded value Wuce%C3%B1o. Acutual value is Wuceño. How to convert the encoded value in decode to get Wuceño in c#?
Try WebUtility.UrlDecode:
string s = WebUtility.UrlDecode("Wuce%C3%B1o");
or HttpUtility.UrlDecode:
string s = HttpUtility.UrlDecode("Wuce%C3%B1o");

Convert decimal to binary but in an 8 bit format [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to pad a binary string with zeros?
I am able to convert decimal numbers to binary but not in an 8 bit format. For example if I input 5 the result is 101 which is correct but how can I show the result in an 8 bit format such as 00000101?
string result = Convert.ToString(num, 2).PadLeft(8, '0');
The simplest way would be to use
string result = Convert.ToString(num, 2).PadLeft(8, '0');

Convert String to Date only in C# [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Convert String to Date in .NET
I new here, I'm stuck with this problem when a have an array of strings with values of "120612" and "200612".
I need to convert the strings to a date format like this, "Tues 12 June, 2012". How will I do that?
Thanks in advance.
DateTime.ParseExact is probably what you're looking for:
DateTime.ParseExact("200612", "ddMMyy", System.Globalization.CultureInfo.CurrentCulture)

String conversion C# [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Convert from scientific notation string to float in C#
Is it there an build-in function which converts string in format "2.71e+006" to a number or I have to write my custom algorithm?
The Decimal Parse method has an overload you can use:
decimal d = Decimal.Parse("2.71e+006", System.Globalization.NumberStyles.Float);
You can also do the same for a Double.

How to convert the following text into a proper string in C#? [duplicate]

This question already has answers here:
How can I decode HTML characters in C#?
(10 answers)
Closed 7 years ago.
How to convert the following text into a proper string in C#?
<IconStyle xmlns="http://earth.google.com/kml/2.0"><color>FFFFFFFF</color><scale>1.0</scale><Icon><href>root://icons/palette-5.png</href><x>192</x><y>192</y><w>32</w><h>32</h></Icon></IconStyle><LabelStyle xmlns="http://earth.google.com/kml/2.0"><scale>0</scale></LabelStyle><BalloonStyle xmlns="http://earth.google.com/kml/2.0"><text>$[description]</text><color>FFFFFFFF</color></BalloonStyle>
Forgot to mention the important catch:how to convert the string in a console application in c#?
That is HTML encoded, so:
HttpUtility.HtmlDecode(myHtmlEncodedString);
Reference: http://msdn.microsoft.com/en-us/library/7c5fyk1k.aspx
HttpUtility.HtmlDecode(string)

Categories