How to convert Color to Hex and Hex to Color using C# and VB.NET

To convert a Color to Hex and vice versa using C# and VB.NET you can use the snippets below.

Sample C#

private static String ColorToHex(Color inputColor)
{
	return ColorTranslator.ToHtml(inputColor);
}

private static Color HexToColor(string hexInput)
{
	return ColorTranslator.FromHtml(hexInput);
}

Sample VB.NET (autoconverted)

Private Shared Function ColorToHex(inputColor As Color) As [String]
	Return ColorTranslator.ToHtml(inputColor)
End Function

Private Shared Function HexToColor(hexInput As String) As Color
	Return ColorTranslator.FromHtml(hexInput)
End Function

Please rate this snippet

How to remove columns from DataTable in C# and VB.NET

To remove columns from DataTable in C# and VB.NET you can use the snippet below.

Sample C#

DataTable dataTable;
dataTable.Columns.Remove("Columnname");
dataTable.Columns.RemoveAt(index);

Sample VB.NET

Dim dataTable As DataTable
dataTable.Columns.Remove("Columnname")
dataTable.Columns.RemoveAt(index)

Please rate this snippet