Solved

C# class file name

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
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.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

756 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