Compiling Your Program

Ultimately, all that computers can manipulate are binary on and off values– everything the computer does boils down to these elements. Everything the computer knows how to do is expressed in a small list of commands called opcodes that are built in to the hardware of the machine. Even these instructions are expressed in binary form. You can write a program by entering those numbers directly into the computer in binary notation. (In fact, that’s exactly how the first home computer, the Altair, was operated.)

However, this kind of programming, called machine language programming, is tedious and error-prone. The computer can work well with a program in machine language, but writing machine language properly is very difficult for programmers. Computer scientists devised programming languages to make the job easier. Although the syntax of a language such as C# is not much like English, C# is far easier for a programmer to understand and use than machine language. However, computers cannot work directly with the code written in C# or any other high-level language. For the computer to do anything with your program, your program has to be translated (compiled) into machine language.

Fortunately, the Visual Studio IDE makes compiling and running your programs simple. Click the blue arrow that looks like a VCR play button, near the top center of the IDE screen. If all goes well, you will see a black screen that looks like Figure 1.11.

Figure 1.11. The Play button compiles and runs your program.


The black screen featured in Figure 1.12 is the console.

Figure 1.12. A cheerful greeting from the Hello World program.


Congratulations! You have written your first program. If you look around on the menu structure created by the C# environment, you will see that you have a HelloWorld.exe file. If you double-click that file, your program will run. (Cool, huh?)

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.239.182