Advertisement
Ahmed-Abdelhameed

Testing `ColorTranslator.FromHtml` with ARGB hex values.

Oct 27th, 2019
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.54 KB | None | 0 0
  1. try
  2. {
  3.     // Incrementing by 5 to save time. Using `++` would cover all possible values but takes a long time.
  4.     for (int a = 0; a <= 255; a += 5)
  5.         for (int r = 0; r <= 255; r += 5)
  6.             for (int g = 0; g <= 255; g += 5)
  7.                 for (int b = 0; b <= 255; b += 5)
  8.                     ColorTranslator.FromHtml($"#{a.ToString("X2")}{r.ToString("X2")}{g.ToString("X2")}{b.ToString("X2")}");
  9.     Console.WriteLine("All is good!");
  10. }
  11. catch (FormatException ex)
  12. {
  13.     Console.WriteLine($"Failed. Message='{ex.Message}'");
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement