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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Richard Muller

    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


  • Daniel O'Connell

    #2
    Re: File name vs Class name - don't need to match like java?

    No, no match must exist.

    "Richard Muller" <RichardLMuller DELETE@comcast. net> wrote in message
    news:ui9PiGQnDH A.744@tk2msftng p13.phx.gbl...[color=blue]
    > 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[/color]
    a[color=blue]
    > similar situation)
    > - ran the .exe and it ran fine.
    >
    > So is it generally true that no match between class name and file name[/color]
    must[color=blue]
    > exist?
    >
    > --
    > TIA,
    > Richard
    >
    > 640K ought to be enough for anybody.
    > Bill Gates, 1981
    >
    >[/color]


    Comment

    • Richard Muller

      #3
      Re: File name vs Class name - don't need to match like java?

      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.4442 9$Fm2.21356@att bi_s04...[color=blue]
      > No, no match must exist.
      >
      > "Richard Muller" <RichardLMuller DELETE@comcast. net> wrote in message
      > news:ui9PiGQnDH A.744@tk2msftng p13.phx.gbl...[color=green]
      > > 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[/color][/color]
      in[color=blue]
      > a[color=green]
      > > similar situation)
      > > - ran the .exe and it ran fine.
      > >
      > > So is it generally true that no match between class name and file name[/color]
      > must[color=green]
      > > exist?
      > >
      > > --
      > > TIA,
      > > Richard
      > >
      > > 640K ought to be enough for anybody.
      > > Bill Gates, 1981
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • Grant Richins [MS]

        #4
        Re: File name vs Class name - don't need to match like java?

        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" <RichardLMuller DELETE@comcast. net> wrote in message
        news:ui9PiGQnDH A.744@tk2msftng p13.phx.gbl...[color=blue]
        > 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[/color]
        a[color=blue]
        > similar situation)
        > - ran the .exe and it ran fine.
        >
        > So is it generally true that no match between class name and file name[/color]
        must[color=blue]
        > exist?
        >
        > --
        > TIA,
        > Richard
        >
        > 640K ought to be enough for anybody.
        > Bill Gates, 1981
        >
        >[/color]


        Comment

        • Richard Muller

          #5
          Re: File name vs Class name - don't need to match like java?

          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


          Comment

          Working...