How to convert RGB to hex in C#

1 Answer

0 votes
using System;

class Program
{
    static void Main() {
        int r = 80;
        int g = 125;
        int b = 210;

        string hex = string.Format("#{0:X2}{1:X2}{2:X2}", r, g, b); 
        
        Console.Write(hex);
    }
}
 
 
 
/*
run:
 
#507DD2
 
*/

 



answered Dec 28, 2021 by avibootz

Related questions

1 answer 69 views
1 answer 55 views
1 answer 119 views
2 answers 113 views
2 answers 85 views
2 answers 98 views
2 answers 99 views
...