VB.NET
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
’Put user code to initialize the page here
Response.Write(ToHexColor(Color.Blue))
End Sub
Function ToHexColor(ByVal c As Color) As String
Return '#' + c.ToArgb().ToString('x').Substring(2)
End Function
C#
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
Response.Write(ToHexColor(Color.Blue));
}
string ToHexColor(Color c )
{
return '#' + c.ToArgb().ToString('x').Substring(2);
}
Share with