?
Solved

C# class file name

Posted on 2012-03-15
4
Medium Priority
?
279 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 34

Accepted Solution

by:
Paul MacDonald earned 1200 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 800 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 1200 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

801 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