Pregunta

I have a problem in compiling an .cs file in the windows cmd.

I have a class Client.cs and in this class I use an instance of another class Student.cs (they are in the same package so no using/import needed).

I successfully compiled the Client.cs file with the Student.cs instance not used as follows:

C:\WINDOWS\Microsoft.NET\Framework\v3.5\csc.exe Client.cs

When decomment the line where i use the instance of that class i get the following error message when compiling :

Client.cs(29,18): error CS0246: The type or namespace name 'Student' could not
        be found (are you missing a using directive or an assembly reference?)

My question is how can i compile my Client.cs file with the compiler "knowing" about that Student.cs. I should add that in Visual Studio it works well. Thank you.

¿Fue útil?

Solución

You have to compile both files at the same time:

C:\WINDOWS\Microsoft.NET\Framework\v3.5\csc.exe Client.cs Student.cs

otherwise the compiler won't know that the class Student even exists.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top