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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:16:18+00:00 2026-05-25T21:16:18+00:00

Possible Duplicate: C# classes in separate files? I came to a new company and

  • 0

Possible Duplicate:
C# classes in separate files?

I came to a new company and found that a C# project had in it a single source file.., that had within it two interfaces and two public classes. (Truth is this is how they do things in most of their projects.) Neither of the three classes were nested. They did however have a chain of inheritance.., starting with on of the two classes using dependency injection.

Question 1:
So my question really is NOT regarding the pattern as much as what is good practice regarding whether or not each of these interfaces should be in on single source file or a source file per class or interface?
Question 2:
Is there a good blog, forum, link, or book addressing this issue?

I don’t instantly like this kind of practice with a single source file being used. I’m use to single a source file per class or interface. I like a source file per class or interface because it gives me file level browse regarding encapsulation possibilities. Also the name of the file starts with ISomething and then has two public classes in it. 🙁

  • 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-25T21:16:18+00:00Added an answer on May 25, 2026 at 9:16 pm

    It is a bad practice only if it violates name-matches-content rule. So if you have Foo.cs and inside you got class Foo and Bar, then that would be a problem. However it is totally cool to have to have Vehicles.cs with classes Car and Truck inside.

    This is just my personal rule that served me well.

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

Sidebar

Related Questions

Possible Duplicate: How to name C# source files for generic classes We are currently
Possible Duplicate: How many Python classes should I put in one file? Coming from
Possible Duplicate: CSS Selector that applies to elements with two classes I've got the
Possible Duplicate: At runtime, find all classes in a Java application that extend a
Possible Duplicate: java class declaration <T> Sometimes I've seen that java classes are created
Possible Duplicate: NetBeans PHP code completion For classes that I created myself an which
Possible Duplicate: When to Use Static Classes in C# Questions in the title..........i would
Possible Duplicate: Ternary Expression with Interfaces as a Base Class Classes: interface ISms {
Possible Duplicate: C++ templates that accept only certain types For example, if we want
Possible Duplicate: XPath: How to match attributes that contain a certain string I'm trying

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.