473,407 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

File name vs Class name - don't need to match like java?

Hi All,

I wrote a HelloWorld.cs with HelloWorld class - I compiled it and it ran
fine.

I wanted to confirm that a class name had to match the file name, so I:
- copied the .cs file to HelloWorld2.cs
- compiled the new .cs and got HelloWorld2.exe (javac would have balked in a
similar situation)
- ran the .exe and it ran fine.

So is it generally true that no match between class name and file name must
exist?

--
TIA,
Richard

640K ought to be enough for anybody.
Bill Gates, 1981
Nov 15 '05 #1
4 1590
No, no match must exist.

"Richard Muller" <Ri******************@comcast.net> wrote in message
news:ui*************@tk2msftngp13.phx.gbl...
Hi All,

I wrote a HelloWorld.cs with HelloWorld class - I compiled it and it ran
fine.

I wanted to confirm that a class name had to match the file name, so I:
- copied the .cs file to HelloWorld2.cs
- compiled the new .cs and got HelloWorld2.exe (javac would have balked in a similar situation)
- ran the .exe and it ran fine.

So is it generally true that no match between class name and file name must exist?

--
TIA,
Richard

640K ought to be enough for anybody.
Bill Gates, 1981

Nov 15 '05 #2
Hi Daniel,

Thanks for the confirmation.

After I posted my question, I found the /main switch which handles the
exceptional case that more than one class containing a static void Main(),
in which case the ambiguity must be resolved with /main:classname.

I also found that the output file name is taken from the source file that
contains the relevant static void Main(), unless a /out option is provided:
/out:filename.

I feel like I'm on a little firmer ground now, until I hit my next
quagmire.

Again, thanks for your help.

Regards,
Richard Muller
"Daniel O'Connell" <onyxkirx@--NOSPAM--comcast.net> wrote in message
news:Exlnb.44429$Fm2.21356@attbi_s04...
No, no match must exist.

"Richard Muller" <Ri******************@comcast.net> wrote in message
news:ui*************@tk2msftngp13.phx.gbl...
Hi All,

I wrote a HelloWorld.cs with HelloWorld class - I compiled it and it ran
fine.

I wanted to confirm that a class name had to match the file name, so I:
- copied the .cs file to HelloWorld2.cs
- compiled the new .cs and got HelloWorld2.exe (javac would have balked
in a
similar situation)
- ran the .exe and it ran fine.

So is it generally true that no match between class name and file name

must
exist?

--
TIA,
Richard

640K ought to be enough for anybody.
Bill Gates, 1981


Nov 15 '05 #3
And you can even have as many classes in one source file as you want (nested
or non-nested).

--
--Grant
This posting is provided "AS IS" with no warranties, and confers no rights.
"Richard Muller" <Ri******************@comcast.net> wrote in message
news:ui*************@tk2msftngp13.phx.gbl...
Hi All,

I wrote a HelloWorld.cs with HelloWorld class - I compiled it and it ran
fine.

I wanted to confirm that a class name had to match the file name, so I:
- copied the .cs file to HelloWorld2.cs
- compiled the new .cs and got HelloWorld2.exe (javac would have balked in a similar situation)
- ran the .exe and it ran fine.

So is it generally true that no match between class name and file name must exist?

--
TIA,
Richard

640K ought to be enough for anybody.
Bill Gates, 1981

Nov 15 '05 #4
Hi Gentlemen,

Thanks for the confirmation.

After I posted my question, I hunted through the VS.Net's help system and
found additional info that was helpful.

I found the /main switch which handles the exceptional case that more than
one class containing a static void Main(), in which case the ambiguity must
be resolved with /main:classname.

I also found that the output file name is taken from the source file that
contains the relevant static void Main(), unless an /out:filename option is
provided.

I feel like I'm on a little firmer ground now, until I hit my next
quagmire.

Again, many thanks to both of you for your help.

Regards,
Richard Muller
Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: webster | last post by:
ok im having a go at creating a jar file. i am using cmd to do it. In the folder that all my class and stuff is in i used the command "jar cf Jrum.jar DrumMachine.class play.gif stop.gif hithat.wav...
8
by: Fu Bo Xia | last post by:
the java.lang.Object.forName method takes a java class name and returns a Class object associated with that class. eg. Class myClass = Object.forName("java.lang.String"); by if i only know the...
4
by: Hal Vaughan | last post by:
I want to have a config file for my program, which means I need to know where the config file is. If I type: java myclass and it runs myclass.class, is there any way to obtain the location of...
48
by: Joseph | last post by:
Hi I'm writing a commercial program which must be reliable. It has to do some basic reading and writing to and from files on the hard disk, and also to a floppy. I have foreseen a potential...
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
1
by: Roy | last post by:
Hi, I have a problem that I have been working with for a while. I need to be able from server side (asp.net) to detect that the file i'm streaming down to the client is saved...
1
by: vj | last post by:
How i can populate all fileds dynamically in jsp page based on contents found in xml file? I have written jsp servlets and java class file. i transferred automatic data from jsp to servlet then to...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
1
by: shapper | last post by:
Hello, I am trying to convert an Asp.Net XML sitemap file in a Google XMl sitemap file using a XSL file using an HttpHandler. Everything seems well in my code but I am getting an error: XML...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.