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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:18:19+00:00 2026-05-26T18:18:19+00:00

Would it be considered a bad practice to nest a private static class inside

  • 0

Would it be considered a bad practice to nest a private static class inside of a non-static class?

public class Outer
{
    private static class Inner
    {


    }
}

The idea here is that all instances of ‘Outer’ would share access to the static state. Another way to do it might be to just let the Inner class be non-static and use a static instance of it:

public class Outer
{
    private static innerInstance = new Inner(); 

    private class Inner
    {


    }
}

Similar effect. What are the pros / cons or other considerations with this approach?

I must admit that I almost never use nested classes, whether static or not, but I am interested in this particular concept..

  • 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-26T18:18:19+00:00Added an answer on May 26, 2026 at 6:18 pm

    Both approaches are entirely valid.

    I wish developers would use private nested classes more often. In conjunction with c#’s partial keyword, it makes writing very complex classes much more maintainable. Imagine needing to build a class that has the complexity of a small application – much easier when you actually can build an entire private application, with classes that are totally internal to your complex outer class!

    One very common case I’ve seen is enumerables – these can be quite complex, especially when you start building custom iterators that can be chained, like LINQ. Hiding the complexity inside the individual classes is the very definition of encapsulation.

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

Sidebar

Related Questions

Would this code be considered bad practice: <div id=sidebar> <% =DisplayMeetings(12) %> </div> This
Would it be considered bad practice to use sub-namespaces for purely organizational purposes? For
Possible Duplicate: Is it considered bad practice to use non-standard HTML attributes? Hi folks,
Would it be considered bad practice to have a viewmodel that has a property
Would this be considered bad practice? unless Link.exists?(:href => 'example.com/somepage') Domain.where(:domain => 'example.com').first.links.create(:href =>
Would you consider it bad practice to store various user data in a database
I think everyone here would agree that in order to be considered a professional
I think it's considered a bad practice to have controls appearing and disappearing and
Is it considered bad practice to pair function names with classes? For example in
I know that having diamond inheritance is considered bad practice. However, I have 2

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.