Live Chat Icon For mobile
Live Chat Icon

How to convert Color to it’s corresponding Hexadecimal value

Platform: ASP.NET| Category: Miscellaneous

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

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.