-2

Thanks for reading my question. I am very, very new to C# and to mono. I want to learn C# for .Net but since I have a Mac and no windows, I couldn't download Visual Studio Express, etc. I heard about mono and installed it, but the instructions are hard for me to follow, and am not sure if I haven't downloaded everything, if I've stored things in the wrong places, or what, but I can't get a simple Hello World to compile.

I downloaded then installed MonoFramework-MDK-2.10.9_11.macos10.xamarin.x86

My-MacBook-Pro:~$ gmcs --version
Mono C# compiler version 2.10.9.0

My-MacBook-Pro:~$ mono --version
Mono JIT compiler version 2.10.9 (tarball Mon May  7 20:25:51 EDT 2012)
Copyright (C) 2002-2011 Novell, Inc, Xamarin, Inc and Contributors. www.mono-project.com
    TLS:           normal
    SIGSEGV:       normal
    Notification:  kqueue
    Architecture:  x86
    Disabled:      none
    Misc:          debugger softdebug 
    LLVM:          yes(2.9svn-mono)
    GC:            Included Boehm (with typed GC)

To test the installation, I followed the instructions for Hello World at http://www.mono-project.com/Mono_Basics

Then I got 82 errors!

Here's what I typed in the terminal-bash window :

My-MacBook-Pro:~$ gmcs hello.cs
hello.cs(1,0): error CS1525: Unexpected symbol `{'
hello.cs(1,5): error CS1009: Unrecognized escape sequence `\c'
hello.cs(1,5): error CS1009: Unrecognized escape sequence `\c'
hello.cs(3,2): error CS1009: Unrecognized escape sequence `\c'
hello.cs(3,12): error CS1009: Unrecognized escape sequence `\g'
hello.cs(3,12): error CS1009: Unrecognized escape sequence `\g'
hello.cs(3,34): error CS1009: Unrecognized escape sequence `\g'
hello.cs(3,34): error CS1009: Unrecognized escape sequence `\g'
hello.cs(3,52): error CS1009: Unrecognized escape sequence `\g'
hello.cs(3,52): error CS1009: Unrecognized escape sequence `\g'
hello.cs(3,74): error CS1009: Unrecognized escape sequence `\g'
hello.cs(3,74): error CS1009: Unrecognized escape sequence `\g'
hello.cs(4,2): error CS1009: Unrecognized escape sequence `\g'
hello.cs(4,2): error CS1009: Unrecognized escape sequence `\g'
hello.cs(4,23): error CS1009: Unrecognized escape sequence `\g'
hello.cs(4,23): error CS1009: Unrecognized escape sequence `\g'
hello.cs(4,42): error CS1009: Unrecognized escape sequence `\g'
hello.cs(4,42): error CS1009: Unrecognized escape sequence `\g'
hello.cs(4,62): error CS1009: Unrecognized escape sequence `\g'
hello.cs(4,62): error CS1009: Unrecognized escape sequence `\g'
hello.cs(5,1): error CS1009: Unrecognized escape sequence `\m'
hello.cs(5,1): error CS1009: Unrecognized escape sequence `\m'
hello.cs(5,1): error CS1009: Unrecognized escape sequence `\m'
hello.cs(5,1): error CS1009: Unrecognized escape sequence `\m'
hello.cs(5,1): error CS1009: Unrecognized escape sequence `\m'
hello.cs(6,1): error CS1009: Unrecognized escape sequence `\d'
hello.cs(7,1): error CS1009: Unrecognized escape sequence `\p'
hello.cs(7,1): error CS1009: Unrecognized escape sequence `\p'
hello.cs(7,1): error CS1009: Unrecognized escape sequence `\p'
hello.cs(7,1): error CS1009: Unrecognized escape sequence `\p'
hello.cs(9,10): error CS1009: Unrecognized escape sequence `\c'
hello.cs(9,14): error CS1009: Unrecognized escape sequence `\c'
hello.cs(10,7): error CS1009: Unrecognized escape sequence `\c'
hello.cs(10,6): error CS1525: Unexpected symbol `cf4'
hello.cs(10,12): error CS1009: Unrecognized escape sequence `\c'
hello.cs(10,16): error CS1009: Unrecognized escape sequence `\c'
hello.cs(10,26): error CS1009: Unrecognized escape sequence `\c'
hello.cs(10,30): error CS1009: Unrecognized escape sequence `\
'
hello.cs(10,30): error CS1009: Unrecognized escape sequence `\
'
hello.cs(10,33): error CS1012: Too many characters in character literal
hello.cs(12,6): error CS1009: Unrecognized escape sequence `\c'
hello.cs(13,2): error CS1525: Unexpected symbol `
                                                 10'
hello.cs(13,7): error CS1009: Unrecognized escape sequence `\c'
hello.cs(14,6): error CS1009: Unrecognized escape sequence `\c'
hello.cs(15,7): error CS1009: Unrecognized escape sequence `\c'
hello.cs(15,6): error CS1525: Unexpected symbol `cf4'
hello.cs(15,12): error CS1009: Unrecognized escape sequence `\
'
hello.cs(15,12): error CS1009: Unrecognized escape sequence `\
'
hello.cs(15,26): error CS1009: Unrecognized escape sequence `\{'
hello.cs(15,26): error CS1009: Unrecognized escape sequence `\{'
hello.cs(15,31): error CS1009: Unrecognized escape sequence `\
'
hello.cs(16,6): error CS1009: Unrecognized escape sequence `\c'
hello.cs(17,2): error CS1525: Unexpected symbol `
                                                 10'
hello.cs(17,7): error CS1009: Unrecognized escape sequence `\c'
hello.cs(18,6): error CS1009: Unrecognized escape sequence `\c'
hello.cs(19,2): error CS1525: Unexpected symbol `
                                                 10'
hello.cs(19,7): error CS1009: Unrecognized escape sequence `\c'
hello.cs(20,6): error CS1009: Unrecognized escape sequence `\c'
hello.cs(21,7): error CS1009: Unrecognized escape sequence `\c'
hello.cs(21,17): error CS1009: Unrecognized escape sequence `\c'
hello.cs(21,23): error CS1009: Unrecognized escape sequence `\c'
hello.cs(21,27): error CS1009: Unrecognized escape sequence `\
'
hello.cs(21,33): error CS1009: Unrecognized escape sequence `\c'
hello.cs(21,37): error CS1009: Unrecognized escape sequence `\{'
hello.cs(21,37): error CS1009: Unrecognized escape sequence `\{'
hello.cs(21,42): error CS1009: Unrecognized escape sequence `\
'
hello.cs(21,57): error CS1009: Unrecognized escape sequence `\c'
hello.cs(21,68): error CS1009: Unrecognized escape sequence `\c'
hello.cs(21,72): error CS1009: Unrecognized escape sequence `\c'
hello.cs(21,85): error CS1009: Unrecognized escape sequence `\c'
hello.cs(21,90): error CS1009: Unrecognized escape sequence `\c'
hello.cs(21,112): error CS1009: Unrecognized escape sequence `\c'
hello.cs(21,118): error CS1009: Unrecognized escape sequence `\c'
hello.cs(21,122): error CS1009: Unrecognized escape sequence `\
'
hello.cs(21,129): error CS1009: Unrecognized escape sequence `\c'
hello.cs(21,133): error CS1009: Unrecognized escape sequence `\}'
hello.cs(21,133): error CS1009: Unrecognized escape sequence `\}'
hello.cs(21,138): error CS1009: Unrecognized escape sequence `\
'
hello.cs(21,138): error CS1009: Unrecognized escape sequence `\
'
hello.cs(21,141): error CS1012: Too many characters in character literal
hello.cs(22,1): error CS1009: Unrecognized escape sequence `\c'
hello.cs(22,5): error CS1009: Unrecognized escape sequence `\}'
Compilation failed: 82 error(s), 0 warnings

This is what my hello.cs file contains:

using System;
 
public class HelloWorld
{
    static public void Main ()
    {
        Console.WriteLine ("Hello Mono World");
    }
 
}

I copied and pasted exactly what was provided at http://www.mono-project.com/Mono_Basics into TextEdit and created the file as an .rtf then changed the extension to .cs

Can someone tell me what I've done (or not done) to create this mess? Thanks.

inf3rno
  • 24,976
  • 11
  • 115
  • 197

2 Answers2

18

I copied and pasted exactly what was provided at http://www.mono-project.com/Mono_Basics into TextEdit and created the file as an .rtf then changed the extension to .cs

Yes, don't do that. Create it as a plain text file. RTF is not plain text. It might look like plain text when shown in an RTF viewer/editor, but what you have done is essentially the same as creating the file in Word, and then expecting gmcs to read the Word document.

It must be a plain text file, with the contents as shown in the example.

Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900
2

I think this is the problem:

as an .rtf then changed the extension to .cs

Try to edit the cs file in some basic text editor.

Tomas Grosup
  • 6,396
  • 3
  • 30
  • 44