File does not contain a valid CIL image [closed]

I installed mono on my suse 12.1. When I create a file say hello.cs and run mono hello.cs on the terminal, I get this error:

Cannot open assembly 'hello.cs': File does not contain a valid CIL image.

The contents of the file(hello.cs) are as below

class hello{
        static void main (){
                System.Console.WriteLine("Hello World");
        }
}

What could be the problem and how do i solve it?


Solution 1:

The mono command is used to run compiled C# programs. You need to compile hello.cs first with:

mcs hello.cs

Then you can execute it with:

mono hello.exe

For more information on writing C# programs with Mono see: http://www.codeproject.com/Articles/9407/Introduction-to-Mono-Your-first-Mono-app