compiler for C#?

Discussion in 'Mac Programming' started by twoodcc, Jan 8, 2007.

  1. macrumors P6

    twoodcc

    Joined:
    Feb 3, 2005
    Location:
    Right side of wrong
    #1
    ok, so the new semester begins, and i'm taking intro to programming with C#.

    can i do this with OS X, or should i install windows through bootcamp?

    thanks
     
  2. Moderator emeritus

    Joined:
    Jun 25, 2002
    Location:
    Gone but not forgotten.
    #2
    You might do a search on Mono. It's the non-Microsoft .NET environment. I'd imagine that there is already a C# compiler but I haven't looked for one.
     
  3. macrumors member

    Joined:
    May 14, 2004
    #3
    Whether or not you can do it in part depends on whether you are going to need to do any GUI programming. If all you're developing are command line tools and you're staying within the core of C# (not using anything from Windows-specific .NET namespaces) then you can probably use Mono with no problem. The Mono documentation will tell you what's implemented and what's not. That might help you decide. Take a look at http://www.mono-project.com/Main_Page. I haven't tried it so I can't recommend it but you can also take a look at http://www.dotgnu.org/.

    Things may have changed but my experience in school was that professors like uniformity so you may want to ask before using what may be considered a non-standard dev environment.
     
  4. macrumors 6502a

    jalagl

    Joined:
    Jun 5, 2003
    Location:
    Costa Rica
    #4
    I tried Mono, and, even though the API support is really coming together (specially for web pages), still has some way to go to match the .NET support found in Windows.

    I would recommend that you start in Windows with the freely available Visual Studio Express. You can get the C# version and start coding. A good site to start learning is Microsoft's Coding4fun, and obviously MSDN.

    And, if you only need the compiler + documentation, you can download The .NET Framework SDK.
     
  5. thread starter macrumors P6

    twoodcc

    Joined:
    Feb 3, 2005
    Location:
    Right side of wrong
    #5
    thanks for the replies. i download Mono, and i'm trying to install a plugin for Xcode, but i can't figure out how to install it yet.

    i'll probably just install windows via bootcamp though.
     
  6. thread starter macrumors P6

    twoodcc

    Joined:
    Feb 3, 2005
    Location:
    Right side of wrong
    #6
    well i finally got Mono working in Xcode. so can i compile something that will also work on windows as well?
     
  7. thread starter macrumors P6

    twoodcc

    Joined:
    Feb 3, 2005
    Location:
    Right side of wrong
    #7
    well after i created a test program in xcode, i can't seem to complie it. or at least i don't think so. it made an ".exe" file, but when i try to run that file on my roommate's pc, it doesn't really do anything.

    here is my code:

    Code:
    //
    //  
    //  Test
    //
    //  Created by Tim Wood on 1/8/07.
    //  Copyright 2007 __MyCompanyName__. All rights reserved.
    //
    //
    
    using System;
    using System.Collections.Generic;
    using System.Text;
    
    namespace Test
    {
    	public class Test
    	{
    		public static void Main(string[] args)
    		{
    			Console.WriteLine( woodtest.TextToDisplay());
    			return;
    		}
    	}
    }
    is this code any good?

    how can i make it work in windows?

    thanks
     
  8. Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #8
    I think it should work on a PC, as long as they have .NET 1.1 installed. Also, since it's a command line app, make sure you execute it through the command prompt (Start > Run > "cmd").
     
  9. thread starter macrumors P6

    twoodcc

    Joined:
    Feb 3, 2005
    Location:
    Right side of wrong
    #9
    thanks. so after i go to the command prompt, how do i execute the program?
     
  10. thread starter macrumors P6

    twoodcc

    Joined:
    Feb 3, 2005
    Location:
    Right side of wrong
    #10
    nevermind, we got it to run in the command prompt. thanks, i'm excited that it worked!

    i wonder why you couldn't just double click the .exe file?

    anyways, i'm just glad that it worked though:)
     
  11. Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #11
    You don't half to run it through the command prompt, but unless your program has a method of pausing, it will show up for a brief milisecond and then go away. That is why you need to run it through the command prompt, so you can see the program's output.

    The easiest way is to drag the exe into the window, and hitting Enter.
     
  12. thread starter macrumors P6

    twoodcc

    Joined:
    Feb 3, 2005
    Location:
    Right side of wrong
    #12
    oh ok, that's what i thought it was doing, but it was so quick that i couldn't tell if it showed anything in the command prompt that came up or not.

    thanks, i'll remember to just drag the exe over next time.

    thanks for the help :)
     
  13. Editor emeritus

    longofest

    Joined:
    Jul 10, 2003
    Location:
    Falls Church, VA
    #13
    if you write a batch script and don't put "pause" in at the end, if you double-click it and it is a really short execution, it may flash before your eyes as well...

    for instance, try making a batch script with just the command "dir" in there, and see how long it takes :)
     
  14. thread starter macrumors P6

    twoodcc

    Joined:
    Feb 3, 2005
    Location:
    Right side of wrong
    #14
    yeah, it was so quick it looked like the command prompt opened and then closed right away.

    what does "dir" do?
     
  15. macrumors member

    Joined:
    May 14, 2004
    #15
    "dir" does on DOS/Windows essentially what "ls" does on UNIX - it gives you a directory listing.

    If you want your command line C# program to pause before closing add a call to Console.ReadLine() at the end of your code and the command prompt window will stay open until you hit return or manually close it.
     
  16. thread starter macrumors P6

    twoodcc

    Joined:
    Feb 3, 2005
    Location:
    Right side of wrong
    #16
    can't you use "ls" in DOS/Windows also?

    thanks for the tip. i might just try that for fun :)
     
  17. Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #17
  18. thread starter macrumors P6

    twoodcc

    Joined:
    Feb 3, 2005
    Location:
    Right side of wrong
    #18
    well that answers my question. :) i guess i wasn't paying enough attention to what my roommate was typing

    but i'm a little confused. i'm supposed to turn in a program after i compile it. but i'm supposed to turn in the .cs file. so why do i need to compile it if i'm only turning in the .cs file and not the .exe file?
     
  19. macrumors member

    Joined:
    May 14, 2004
    #19
    Probably because it's a quick and dirty check that your program is free from the kinds of errors that the compiler can catch. If it doesn't compile then you know you still have work to do before submitting it. Think of it like this: if you were taking an electronics course you might be required to submit a schematic of a circuit you've designed. The teacher might, however, also require you to build the circuit so that you have some level of confidence that it's possible. In this sense what you're being asked to do is have your program in a runnable condition before you submit the source.

    That said, the fact that it compiles doesn't guarantee that your program does anything or does what you intend but it does indicate that the program is minimally well-formed.
     
  20. thread starter macrumors P6

    twoodcc

    Joined:
    Feb 3, 2005
    Location:
    Right side of wrong
    #20
    thanks. after thinking about it i came to the conclusion that you need the compiler to make sure that your program works.
     

Share This Page