using system;

public class Hello{
public static void main(){
console.WriteLine("Hello C# World :)");
}
}

This is code I just wrote and ran it as hello.cs ..... I got this error.

C:\learncs\csc/nologo/out:hello.exe hello.cs
'csc' is not recognized as an internal or external command,
operable program or batch file.

What could be the reasons ..... ?
Please help ....thnx :)

Recommended Answers

All 6 Replies

You probably got to set the PATH variable in your environment.
If by any means you can, use Visual Studio C#.

Well ..... sir I do have visual C# 2008 installed in my computer ......
But I have just started with this ......
Could you please tell me how work on that ??? and,
What should be the path variable ...... !!!????

Thanx..... !

If you have Visual Studio, start a new ConsoleApplication project name in Hello or whatever.
In the Main method you see type the following:

Console.WriteLine("Hello world!");
Console.ReadKey();

Run this by clicking on a small green triangle. Et voilĂ !

using system;

public class Hello{
public static void main(){
console.WriteLine("Hello C# World :)");
}
}

Maybe the problem lies in the "console" keyword (Console class) because it is written wth small initial. You have to write it with a big initial, like "Console".

This works:

using System;

namespace Apr01Test1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello C# world.");
            Console.ReadLine();
        }
    }
}

The error produced is showin that you have just typed csc in
DOS prompt. A csc command can only be typed when the DOS prompt is opened in
the C# directory.
Try executing the csc with the full path of it preceding it.
The command may be something like this

<Drive where csc located>:\<path of csc>\csc.exe

ex.)
C:\Program Files\VS 2008\csc.exe

the above is just an example.


and then give the parameters (i.e) the file name to be compiled etc.
of course as Mitja Bonca says you have some syntax errors which may produce only
compile time errors which can be rectified.

The value of your PATH variable will show when you type PATH at the command promt.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.