Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# hex to console color

public static ConsoleColor FromHex(string hex)
    {
        int argb = Int32.Parse(hex.Replace("#", ""), NumberStyles.HexNumber);
        Color c = Color.FromArgb(argb);
        
        int index = (c.R > 128 | c.G > 128 | c.B > 128) ? 8 : 0; // Bright bit
        index |= (c.R > 64) ? 4 : 0; // Red bit
        index |= (c.G > 64) ? 2 : 0; // Green bit
        index |= (c.B > 64) ? 1 : 0; // Blue bit
        
        return (System.ConsoleColor)index;
    }
Comment

c# console background color

Console.BackgroundColor = ConsoleColor.Green;
Comment

c# console foreground color

Console.ForegroundColor = ConsoleColor.DarkGreen;
Comment

c# console foreground color

//Background color
Console.BackgroundColor = ConsoleColor.Green;
//Foreground color
Console.ForegroundColor = ConsoleColor.Black;
//Reset
Console.ResetColor();
Comment

c# color to console color

 public static ConsoleColor FromColor(Color c)
        {
            int index = (c.R > 128 | c.G > 128 | c.B > 128) ? 8 : 0; // Bright bit
            index |= (c.R > 64) ? 4 : 0; // Red bit
            index |= (c.G > 64) ? 2 : 0; // Green bit
            index |= (c.B > 64) ? 1 : 0; // Blue bit

            return (System.ConsoleColor)index;
        }
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# add key value pair to dictionary 
Csharp :: if list does not contain then add c# 
Csharp :: c# best way to loop and remove 
Csharp :: How to add rigidbody as a variable 
Csharp :: instantiate prefab unity 
Csharp :: c# recursion formula for the factorial 
Csharp :: iterate though data in firebase unity 
Csharp :: recursively reverse linked list 
Csharp :: c# delete files 
Csharp :: XMLWriter write xml C# 
Csharp :: c# max function 
Csharp :: unity pause coroutine 
Csharp :: c# increment by 1 
Csharp :: how to have referecne to script in unity 
Csharp :: dynamically add rows to datagridview c# 
Csharp :: c# for 
Csharp :: c# make a automapper 
Csharp :: c# bootstrap checkbox 
Csharp :: c# float 
Csharp :: c# $ string 
Csharp :: double parse csharp removes decimal 
Csharp :: nunit cleanup after all tests 
Csharp :: indexof c# 
Csharp :: c# Remove String In C# 
Csharp :: unity reload active scene 
Csharp :: c# remove xml invalid characters 
Csharp :: c# progress bar timer 
Csharp :: unity get distance between line and point 
Csharp :: declare multiple variables in for loop C# 
Csharp :: c# ip address to string 
ADD CONTENT
Topic
Content
Source link
Name
9+5 =