Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

twoodcc

macrumors P6
Original poster
Feb 3, 2005
15,307
26
Right side of wrong
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
 

bousozoku

Moderator emeritus
Jun 25, 2002
16,120
2,397
Lard
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.
 

Grover

macrumors member
May 14, 2004
48
0
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.
 

jalagl

macrumors 6502a
Jun 5, 2003
802
1
Costa Rica
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.
 

twoodcc

macrumors P6
Original poster
Feb 3, 2005
15,307
26
Right side of wrong
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.
 

twoodcc

macrumors P6
Original poster
Feb 3, 2005
15,307
26
Right side of wrong
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
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
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").
 

twoodcc

macrumors P6
Original poster
Feb 3, 2005
15,307
26
Right side of wrong
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").

thanks. so after i go to the command prompt, how do i execute the program?
 

twoodcc

macrumors P6
Original poster
Feb 3, 2005
15,307
26
Right side of wrong
thanks. so after i go to the command prompt, how do i execute the program?

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:)
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
thanks. so after i go to the command prompt, how do i execute the program?

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.
 

twoodcc

macrumors P6
Original poster
Feb 3, 2005
15,307
26
Right side of wrong
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.

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 :)
 

longofest

Editor emeritus
Jul 10, 2003
2,931
1,715
Falls Church, VA
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 :)
 

twoodcc

macrumors P6
Original poster
Feb 3, 2005
15,307
26
Right side of wrong
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 :)

yeah, it was so quick it looked like the command prompt opened and then closed right away.

what does "dir" do?
 

Grover

macrumors member
May 14, 2004
48
0
"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.
 

twoodcc

macrumors P6
Original poster
Feb 3, 2005
15,307
26
Right side of wrong
"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.

can't you use "ls" in DOS/Windows also?

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

Grover

macrumors member
May 14, 2004
48
0
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.
 

twoodcc

macrumors P6
Original poster
Feb 3, 2005
15,307
26
Right side of wrong
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.

thanks. after thinking about it i came to the conclusion that you need the compiler to make sure that your program works.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.