How I could convert a ConsoleColor
to a Color
type?
I need this for create an overload of this method, which should return a color instead a Consolecolor:
''' <summary>
''' Generates a random ConsoleColor color.
''' </summary>
''' <returns>ConsoleColor.</returns>
Public Shared Function [ConsoleColor]() As ConsoleColor
Dim Rand As New Random
Return [Enum].Parse(GetType(ConsoleColor),
Rand.Next(0, 15))
End Function
This is what I've tried, but sometimes the returned color is empty because the ConsoleColor name is unknown:
''' <summary>
''' Generates a random QB color.
''' </summary>
''' <returns>Color.</returns>
Public Shared Function QB() As Color
Dim Rand As New Random
Return Color.FromName([Enum].Parse(GetType(ConsoleColor),
Rand.Next(0, 15)).ToString)
End Function
PS: I want to avoid the usage of old VB6 methods (QBColor function).