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 539989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:11:37+00:00 2026-05-13T10:11:37+00:00

I am trying to make a class helper for the Color class in C#.

  • 0

I am trying to make a class helper for the Color class in C#. I am a Delphi programmer and as far as I know, class helpers allow you to expand base classes so when you create an instance of the base class, you have access not only to the base methods, but also to all those defined in the helper class.
Is it possible to achieve a similar effect in C#? Let’s say, I have the following static method:

public static Color AdjustForeColor(Color backColor)
{
  double mediumColor = ((0.3 * 255.0) + (0.59 * 255.0) + (0.11 * 255.0)) / 2.0;
  if ((0.3 * backColor.R) + (0.59 * backColor.G) + (0.11 * backColor.B) > mediumColor)
    return Color.Black;
  else
    return Color.White;
}

It adjusts the font colour to the background so that it stays readable.
I would like this method to be accessible through the Color class (Color.AdjustForeColor()). How to do that?

Thanks in advance.

Mariusz.

  • 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-13T10:11:38+00:00Added an answer on May 13, 2026 at 10:11 am

    It is called extension methods in C#

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

Sidebar

Related Questions

I am trying to make Http connections made by C# HttpClient helper class reusable.
I am trying to extend the mysqli class to make a helper class that
I'm trying to make tiny helper method for simplify routine operations But on the
Here is my post: I'm trying to make myself as clear as possible: Description
I'm building a conforming and validating XML parser in C++ and trying to make
Okay so I'm trying to make a little gag program that will run away
I'm getting a NoMethodError when trying to access a method defined in one of
I'm trying to figure out what the better/cleaner/more maintainable way is, for the following
I have been googling and stackoverflowing for the last two hours and couldn't find

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.