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

  • SEARCH
  • Home
  • 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 8367743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:14:09+00:00 2026-06-09T13:14:09+00:00

I have various objects in my database identified by unique System.Guid’s . When I

  • 0

I have various objects in my database identified by unique System.Guid's. When I display them, I would like each of them to have a unique color based on their guid.

So I want something like this:

public Color ColorFromGuid(Guid guid) { /* ?? */ }

Where

ColorFromGuid(databaseObject1.Guid) == ColorFromGuid(databaseObject1.Guid)
ColorFromGuid(databaseObject2.Guid) == ColorFromGuid(databaseObject2.Guid)
ColorFromGuid(databaseObject1.Guid) != ColorFromGuid(databaseObject2.Guid)

What would be the best way to do this?

EDIT Obviously there are WAY more unique guids than colors, so there’s no way that every guid will have it’s own unique color. I’m just looking for a good variety.

  • 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-06-09T13:14:10+00:00Added an answer on June 9, 2026 at 1:14 pm

    You could do:

    return Color.FromArgb(guid.GetHashCode());
    

    If you need an opaque color, use the overload of Color.FromArgb that lets you specify the alpha. If you want similar GUIDs to generate very different colors, you can do a different sort of hash on the Guid, e.g. an MD5 hash, and get the number to generate your color from that.

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

Sidebar

Related Questions

Lets say you have various objects of arbitrary type that you would like to
I have various objects in application,and each has isvalid method to test if values
I have an array (items) of custom class objects (catalogItem) each catalogItem has various
I have a handful of DBIx::Class::Core objects that model various database tables. For some
I'm designing a database to hold my domain objects. I have various validation rules
I have various styles of font objects grouped into arrays. Each font object has
I have an application which uses code that produces various types of objects and
I have an application which displays properties dialogs for various GUI-accessible objects. Because there
I am using Reflections to adjust various values in objects, and I have an
I have various database fields that are decrypted using the to_python method. The problem

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.