A
A
Alexey Cheban2014-01-03 23:52:02
Programming
Alexey Cheban, 2014-01-03 23:52:02

Why doesn't the csc.exe compiler compile the .cs file type?

Hello, there is such a problem... When compiling the .cs file type (s-sharp source file),
the csc.exe compiler does not compile the .cs file type. When writing programs in the C-sharp language, I use the Sun text editor, I wrote a simple HelloWord program, for example. The following actions are "Save as", then I change the "file name" to "app.cs", I save it all in a folder. And then I compile "app.cs", "Open with" - Visual C# Command Line Compiler, and still no action. (There are no actions).
But it wasn’t there, with the same actions “exactly exactly” but only when saving not “app.cs” but typing “app.csc” or “app.css” and compiling with the Visual C# Command Line Compiler, another one is created a file with the same name but only the extension will be .exe, and voila, if you open this app.exe file, the program works. The problem is that I can't understand why "app.cs" doesn't work according to the same algorithm as "app.csc" or "app.css", and in fact .cs must be compiled because it is a c-sharp extension file.

Answer the question

In order to leave comments, you need to log in

5 answer(s)
C
CAMOKPYT, 2014-01-04
@CAMOKPYT

Why such torment, install Visual Studio

M
Mikhail Doshevsky, 2014-01-05
@MikhailD

Here it is described how to compile the code from the command line. In short:
Where File.cs is the name of your file.
As a result, you will receive File.exe, or an error message.

D
Denis Domansky, 2014-01-04
@Doman

I agree with the previous commenter. Moreover, the Express version is free: www.visualstudio.com/ru-ru/products/visual-studio-...

R
Rsa97, 2014-01-03
@Rsa97

Run the compiler not by mouse clicking, but from the command line, as it should be. You may see what is wrong.

A
Alexey Yakhnenko, 2015-02-05
@evgeniy8705

// просто функция проверяющая, является ли данное ей значение числом
function isNumeric(n) {
  return !isNaN(parseFloat(n)) && isFinite(n);
}

// конструктор объектов типа Калькулятор, считай определение класса
function Calculator() {

  // массив методов калькулятора, каждый из которых есть функция от двух чисел
  // виден только внутри объекта
  var methods = {
    "-": function(a, b) {
      return a - b;
    },
    "+": function(a, b) {
      return a + b;
    }
  };

  // публичный метод калькулятора, собственно его предназначение
  // принимает строку с выражением которое надо вычислить
  this.calculate = function(str) {

    // парсит строку с выражением
    // разбивая ее на 3 части по пробелам
    var split = str.split(' '),
      // создаются три переменные, два числа и операнд
      a = split[0],
      op = split[1],
      b = split[2]

    // валидация переменных
    if(!methods[op] || !isNumeric(a) || !isNumeric(b)) {
      return NaN;
    }

    // достается элемент массива methods под названием op
    // он является функцией
    // ей передаются оба числа и она с ними что-то делает
    // собственно результат ее выполнения возвращается из функции calculate
    return methods[op](+a, +b);
  }

// another public method of the calculator
// takes the name of the function and the function itself
// needed so that new operations can be added to the methods array
this.addMethod = function(name, func) {
methods[name] = func;
};
}
// a new Calculator class object is created
var calc = new Calculator;
// add the ability to multiply two numbers, will be called "*", the function object is attached
calc.addMethod("*", function(a, b) {
return a * b;
});
// similarly, the ability to divide one number by another
calc.addMethod("/", function(a, b) {
return a / b;
});
// similarly, exponentiation
calc.addMethod("**", function(a, b) {
return Math.pow(a, b);
});
// see description this.calculate = function(str) {
var result = calc.calculate("2 ** 3");
alert(result); // eight

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question