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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T23:49:21+00:00 2026-05-18T23:49:21+00:00

I have some classes which have Fonts and Brushes as private fields. Something says

  • 0

I have some classes which have Fonts and Brushes as private fields. Something says me this isn’t correct practice, and should be avoided, yet I don’t know why …. (Darn subconsiousness 🙂 )

Is this true, and why is it bad practice ?

class SomeControl: Panel
{
    private Font titelFont = new Font("Arial", 8.25f, FontStyle.Bold);        
    private SolidBrush whiteBrush = new SolidBrush(Color.White);


    public SomeControl()
    {
        //Do stuff
    }
}
  • 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-18T23:49:22+00:00Added an answer on May 18, 2026 at 11:49 pm

    I don’t see why it’s bad.

    When using brushes, you already have static Brushes class you may want to reuse instead of creating your own (just like you do with common colors).

    For example, instead of creating whiteBrush, you may rather use Brushes.White directly.

    Of course, it gives you only a common set of brushes, so you still need to create your own brush for any other color.

    Just remember than fonts and brushes must be properly disposed. It means that when using your own fonts and brushes as a property or a field of a class, this class must implement IDisposable and properly dispose those fonts and brushes.

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

Sidebar

Related Questions

I've read around about const and static readonly fields. We have some classes which
I'm testing with EF 4.3 (beta) I have some new classes which should generate
I have some DateTime fields on my MVC model classes - some which require
I have a package which contains an interface and several classes,some classes in this
I have some classes which extends a superclass, and in the JSP I want
I have a set of some classes which are all capable of being constructored
I have some functionality that I need in all my classes which derive from
I'm using .NET 3.5. We have some complex third-party classes which are automatically generated
I have four classes which share some arrangement of four properties. I have currently
I have some classes layed out like this class A { public virtual void

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.