TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

<< Back to C-SHARP

C# Color Table

Color Table. Many HTML and system colors are available. We can enumerate these in the C# language and the ASP.NET Framework. We build a table containing all named colors, making HTML easier to write.

Note: Here we see the HTML colors in a table generated using the C# language. Then we see the code that wrote the table.

HTML color table activeborder activecaption activecaptiontext aliceblue antiquewhite appworkspace aqua aquamarine azure beige bisque black blanchedalmond blue blueviolet brown burlywood buttonface buttonhighlight buttonshadow cadetblue chartreuse chocolate coral cornflowerblue cornsilk crimson cyan darkblue darkcyan darkgoldenrod darkgray darkgreen darkkhaki darkmagenta darkolivegreen darkorange darkorchid darkred darksalmon darkseagreen darkslateblue darkslategray darkturquoise darkviolet deeppink deepskyblue desktop dimgray dodgerblue firebrick floralwhite forestgreen fuchsia gainsboro ghostwhite gold goldenrod gradientactivecaption gradientinactivecaption gray graytext green greenyellow highlight highlighttext honeydew hotpink hottrack inactiveborder inactivecaption inactivecaptiontext indianred indigo info infotext ivory khaki lavender lavenderblush lawngreen lemonchiffon lightblue lightcoral lightcyan lightgoldenrodyellow lightgray lightgreen lightpink lightsalmon lightseagreen lightskyblue lightslategray lightsteelblue lightyellow lime limegreen linen magenta maroon mediumaquamarine mediumblue mediumorchid mediumpurple mediumseagreen mediumslateblue mediumspringgreen mediumturquoise mediumvioletred menu menubar menuhighlight menutext midnightblue mintcream mistyrose moccasin navajowhite navy oldlace olive olivedrab orange orangered orchid palegoldenrod palegreen paleturquoise palevioletred papayawhip peachpuff peru pink plum powderblue purple red rosybrown royalblue saddlebrown salmon sandybrown scrollbar seagreen seashell sienna silver skyblue slateblue slategray snow springgreen steelblue tan teal thistle tomato transparent turquoise violet wheat white whitesmoke window windowframe windowtext yellow yellowgreen
Example. We use the Enum.GetNames method and the typeof operator along with the Where extension method. With Where, we remove Control colors from the output. Other articles describe these methods in depth.Enum.GetNameWhere

Tip: To compile the program, add the System.Drawing assembly to your project. When you execute it, all available colors will be printed to the Console.

And: It uses the StartsWith method and LINQ extension methods. These help generate the correct output.

StartsWith, EndsWithLINQ
C# program that generates HTML color table using System; using System.Drawing; using System.Linq; class Program { static void Main() { // Get enum strings and order them by name. // Remove Control colors. foreach (string c in Enum.GetNames(typeof(KnownColor)).Where( item => !item.StartsWith("Control")).OrderBy(item => item)) { // Write table row. Console.WriteLine("<b style=background:{0}>{1}</b>", c.ToLower(), c.ToLower().PadRight(20)); } } }
Discussion. Sometimes we can create our documentation directly from the code and libraries we use. This is one example. The KnownColors can be enumerated and listed. This also helps us learn about how to use this programming language.
Summary. This table contains the KnownColors from the System.Drawing namespace. Next we saw the console program that generates the table. A color sheet can be useful for selecting named colors for Internet articles.
© TheDeveloperBlog.com
The Dev Codes

Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf