String format hexadecimal
string-format-hexadecimal.aspx
<%@ Page Language="C#" AutoEventWireup="true"%>
<!DOCTYPE html>
<script runat="server">
protected void Button1_Click(object sender, System.EventArgs e)
{
//this line create an integer variable.
int intValue = 123456;
Label1.Text = "integer value: " + intValue.ToString();
//string format number to hexadecimal format using string.format method.
Label1.Text += "<br /><br />number in hexadecimal format: " + string.Format("{0:x}", intValue);
Label1.Text += "<br />number in hexadecimal format(0:x6): " + string.Format("{0:x6}", intValue);
Label1.Text += "<br />number in hexadecimal format(0:x8): " + string.Format("{0:x8}", intValue);
Label1.Text += "<br /><br />using ToString method: " + intValue.ToString("x");
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>c# example - string format hexadecimal</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:MidnightBlue; font-style:italic;">
c# example - string format hexadecimal
</h2>
<hr width="550" align="left" color="Gainsboro" />
<asp:Label
ID="Label1"
runat="server"
Font-Size="Large"
>
</asp:Label>
<br /><br />
<asp:Button
ID="Button1"
runat="server"
Text="string format hexadecimal"
OnClick="Button1_Click"
Height="40"
Font-Bold="true"
/>
</div>
</form>
</body>
</html>

- How to convert a string to int
- How to get a substring from a string
- How to convert a string to uppercase characters
- How to convert a string to lowercase characters
- How to format a decimal string as percentage value
- How to convert an integer to fixed length hex string format
- How to format a string with padding
- How to format a string to a fixed length string
- How to replace a character in a string
- How to perform string replace by ignoring case