0% found this document useful (0 votes)
30 views

98 Fundamentals of Computer Programming With C#

The document discusses the steps to create a simple C# console application in Visual Studio, including renaming the default class and file, adding code to the Main method, compiling the code using F6 or Shift+Ctrl+B, and resolving any errors in the Error List window. It also covers starting the project using Ctrl+F5 to run the application and view output in the console.

Uploaded by

Ajla Puhalo
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

98 Fundamentals of Computer Programming With C#

The document discusses the steps to create a simple C# console application in Visual Studio, including renaming the default class and file, adding code to the Main method, compiling the code using F6 or Shift+Ctrl+B, and resolving any errors in the Error List window. It also covers starting the project using Ctrl+F5 to run the application and view output in the console.

Uploaded by

Ajla Puhalo
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

98

Fundamentals of Computer Programming with C#

A dialog window appears asking us if we want to rename class name as well


as the file name. We select "Yes".

Chapter 1. Introduction to Programming

99

After we complete all these steps we have our first console application named

IntroToCSharp and containing a single class HelloCSharp (stored in the file


HelloCSharp.cs):

All we have to do is add code to the Main() method. By default, the


HelloCSharp.cs code should be loaded and ready for editing. If it is not, we
double click on the HelloCSharp.cs file in the Solution Explorer to load it. We
enter the following source code:

100

Fundamentals of Computer Programming with C#

Compiling the Source Code


The compiling process in Visual Studio includes several steps:
- Syntax error check;

- A check for other errors, like missing libraries;


- Converting the C# code into an executable file (a .NET assembly). For
console applications it is an .exe file.
To compile a file in Visual Studio, we press the [F6] key or [Shift+Ctrl+B].
while we are still writing or when compiling, at the latest. They are listed in
the "Error List" window if it is visible (if it is not, we can show it from the
"View" menu of Visual Studio).
If our project has at least one error, it will be marked with a small red " x" in
the "Error List" window. Short info about the problem is displayed for each
error filename, line number and project name. If we double click any of the
errors in the "Error List", Visual Studio will automatically take us to the file
and line of code where the error has occurred. In the screenshot above the

using Systema

using System

Starting the Project


To start the project, we press [Ctrl+F5] (holding the [Ctrl] key pressed and
at the same time pressing the [F5] key).
The program will start and the result will be displayed on the console,
followed by the "Press any key to continue . . ." message:

You might also like