Solved

C# class file name

Posted on 2012-03-15
4
267 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 34

Accepted Solution

by:
Paul MacDonald earned 300 total points
ID: 37724722
Yes.
0
 
LVL 1

Author Comment

by:allelopath
ID: 37724737
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
ID: 37724783
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 34

Assisted Solution

by:Paul MacDonald
Paul MacDonald earned 300 total points
ID: 37725015
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
C# Error - Add Failed 12 78
Why don't I see this table in EDMX file? 2 23
Remove greater than sign 3 42
free scanner TWAIN can be operated with a Web application 9 38
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

911 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

15 Experts available now in Live!

Get 1:1 Help Now