Click here to Skip to main content
15,922,407 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
when i run the SP output as follows

Zone color code
Green-#008000

i want output as follows

Zone color code
Green

this.Zone.InnerText = value.Tables[0].Rows[0]["ZoneColor"].ToString();


for that how can i do in C#

What I have tried:

when i run the SP output as follows

Zone color code
Green-#008000

i want output as follows

Zone color code
Green

this.Zone.InnerText = value.Tables[0].Rows[0]["ZoneColor"].ToString();


for that how can i do in C#
Posted
Updated 26-Jul-16 21:19pm
Comments
Richard MacCutchan 27-Jul-16 3:28am    
Use string.Split.

1 solution

As far I know, this is not completely possible as not every hex color code has a name.
However you can try following things-
1. Retrieve the RGB value of a hexcode
2. Find a closest color name match

To do this check following article-
Find a name for almost any hex color · A Beautiful Site[^]

Here are few other solutions using C#-
c# - convert hex code to color name - Stack Overflow[^]
c# - How to get Color from Hexadecimal color code using .NET? - Stack Overflow[^]

Hope, it helps :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900