Solved

C# class file name

Posted on 2012-03-15
4
266 Views
Last Modified: 2012-03-15
In Java, the class name and the file name of the class must match.
In C#, this does not appear to be the case, ie I can have a file named MyClass.cs with:
public class NotMyClass {
}
Is this correct?
0
Comment
Question by:allelopath
  • 2
4 Comments
 
LVL 33

Accepted Solution

by:
paulmacd earned 300 total points
Comment Utility
Yes.
0
 
LVL 1

Author Comment

by:allelopath
Comment Utility
Is this often done?
or is it best practices to have the class and file name match?
0
 
LVL 29

Assisted Solution

by:Paul Jackson
Paul Jackson earned 200 total points
Comment Utility
Some people have more than one class in a class file so often in this scenario the class file will be called something different.
In my opinion however it is better to have the class file and class name matching and only one class per class file.
0
 
LVL 33

Assisted Solution

by:paulmacd
paulmacd earned 300 total points
Comment Utility
I'm not aware of any standard, so I think it's a matter of personal preference.  Obviously, finding what you're looking for is important so bing smart about it makes sense.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now