Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 974649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:27:59+00:00 2026-05-16T03:27:59+00:00

I know how to convert a string to an XNA Color object , but

  • 0

I know how to convert a string to an XNA Color object, but how do I convert a C# Color object like Color.Blue into its string representation(e.g. “Blue”).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T03:28:00+00:00Added an answer on May 16, 2026 at 3:28 am

    You need to do the reverse of what was done in your previous question:

    1. Convert from XNA color to System color
    2. Try and convert the system color to a known color
    3. If the conversion worked, call ToString on the known color

    e.g.

    // Borrowed from previous question
    using XnaColor = Microsoft.Xna.Framework.Graphics.Color;
    
    System.Drawing.Color clrColor = System.Drawing.Color.FromName("Red"); 
    XnaColor xnaColor = new XnaColor(clrColor.R, clrColor.G, clrColor.B, clrColor.A);
    
    // Working back the other way
    System.Drawing.Color newClrColor = System.Drawing.Color.FromArgb(xnaColor.A, xnaColor.R, xnaColor.G, xnaColor.B);
    System.Drawing.KnownColor kColor = newClrColor.ToKnownColor();
    string colorName = kColor != 0 ? kColor.ToString() : "";
    

    Note: This will give you an empty string if the color name isn’t known.

    [EDIT]
    You might want to try using a TypeConverter here. I’m not sure that one exists for the XNA Color type, but it’s worth a shot:

    string colorName = System.ComponentModel.TypeDescriptor.GetConverter(typeof(Microsoft.Xna.Framework.Graphics.Color)).ConvertToString(yourXnaColor);
    

    [EDIT]

    Since none of the above is going to do what you want, you’ll have to try a similar approach to what Jon has done here: Convert string to Color in C#

    You’ll need to pull all the XNA colors into a dictionary using reflection, like he has done, but reverse the keys and values, so it’s Dictionary, then write a function that accesses the dictionary taking a Color parameter and returning the name.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know how to convert a string that represents a color into a
Any one know how to convert string value into html format in php? For
i have a doubt. May i know how to convert string to int.i know
I know you can convert a String to an number with read : Prelude>
I know that trying to convert string 0 to boolean will fail, I also
Does anyone know how to convert a string from ISO-8859-1 to UTF-8 and back
i made a program which converts lower case to upper case a string.i know
I have the following code: The actual problem is the non-quoted code. I want
I'm trying to extend TextBox control to add watermarking functionality. The example I've found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.