---
title: CSCI 1301 -- Lab 02
author: Clément Aubert
lang: en
fontsize: 10pt
documentclass: scrartcl
numbersections: true
links-as-notes: true
papersize: letter
geometry: margin=1in
keywords:
- Computer Science
- Problem solving methods
- Syllabus
- Augusta University
- Bachelor of Science
---


# How Was the Backup?

Re-download or transfer the files you saved last time (the whole `Welcome` folder) on the computer and make sure you can still open the project with Visual Studio (VS).
Do you remember how to build the solution and start the program without debugging?
Using the shortcuts?
If not, go have another look [at the previous lab](../01/).

If your backup went wrong (you can't open the project, it won't compile, …), try to understand what happened.
Then, [re-download the "Welcome" archive](../01/Welcome.zip), extract it and make sure you can build the solution and start the program without debugging.

# Orientation

Have a look at the following screenshot:

![](recap.png){width=100%}

You should have roughly the same on your computer.
If not, you can zoom to have a better reading.

Answer the following:

#. Where is the file explorer?
#. How many folders are in the folder opened in the file explorer?
#. How many files are in the folder opened in the file explorer?
#. Where is Visual Studio (VS)?
#. Where is the solution explorer?
#. Where is the window where I can edit the source code?
#. What is the output of the building?

# Re-using and Editing

Close Visual Studio (VS).
With the file explorer, create a new folder (call it for instance `02_lab`) and copy the `Welcome` folder in it.
In this exercise, you will rename and edit this copy.

## Renaming

Open with VS the copy of the `Welcome` folder that you just created.
Rename the solution **within** VS:

#. Right-click on "Solution 'Welcome' (1 project)", select "Rename", rename it to "MyFirstProgram".
#. What change(s) do you notice in Visual Studio?
#. Can you still build and debug your program?
#. Look in the file explorer: did the name of the folder changed? Did the name of the `.sln` file changed?

**You should _not_ rename a solution with the file explorer: _always_ use VS to rename.**

## Editing

We will now change (edit) our "MyFirstProgram" solution.

#. In `program.cs`, replace `"Welcome to the lab portion of CSCI 1301!"` with `"This is my first program."`.
#. Build the solution and start the program without debugging. Do you notice any change?
#. Insert a new line after `// This is an in-line comment. ` and before the first `}` sign, and paste the following:

    ~~~~~~~{.cs}
    Console.Write("This is my second message."); 
    ~~~~~~~
#. Build the solution and start the program without debugging. Do you notice any change?
#. Insert another new line after the one you just created, and paste the following: 

    ~~~~~~~{.cs}
    Console.Write("This is my third message."); 
    ~~~~~~~
#. Build the solution and start the program without debugging. Can you notice the difference between `WriteLine` and `Write`?
#. Insert another new line after the one you just created, and paste the following: 

    ~~~~~~~{.cs}
    Console.Write("\t This is my fourth message."); 
    ~~~~~~~
#. Build the solution and start the program without debugging. Can you tell what `\t` is doing?
#. Insert another new line after the one you just created, and paste the following: 

    ~~~~~~~{.cs}
    Console.Write("\n This \n is \n my fifth message.\n");
    ~~~~~~~
#. Build the solution and start the program without debugging. Can you tell what `\n` is doing?
#. Have a look [the documentation page of microsoft on escape sequences](https://docs.microsoft.com/en-us/cpp/c-language/escape-sequences), and edit your program by adding a statement that displays the `\` and the `"` characters.
#. Add a comment (using `//` or `/*` and `*/`) in your program.

Make a back up of what you just did: upload the `02_lab` folder you created previously on your remote backup, or copy it on your thumb drive.
**Do not** use the "Save as…" capacities of VS: close VS and copy / upload the folder "by hand", using the file explorer or a browser.
Re-downloading or re-transfering it and re-opening it is a good way of making sure that your back up was correct.

# Breaking Your Program

If you followed the instructions carefully, your were able to build the solution and start the program without debugging after each step.
As you know, C\# has precise rules, and not respecting them can prevent your solution from being built by VS.

In this exercise, you are asked to do the following:

#. Change the program so that it violates one of the syntax rules of `C#` (refer to your lecture notes, and to the suggestions below).
#. Build the solution, and note that an error is reported. In the build output (cf. the screenshot presented earlier, you may need to click on a tab in VS to see it), you will see a message like 

        ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

#. Click on the "Error list" tab next to the build output, and make sure you understand the error message.
#. Undo your change, using <kbd>Ctrl</kbd> + <kbd>z</kbd>.
#. Make sure you can build the solution without error message anew.

Do it three times, in order to identify three different error messages, and three ways of breaking the rules.

If you have time or lack inspiration, you can try with the following, and see which one(s) make the building impossible (don't forget to undo your change after):

- Remove the semicolon after `using System`
- Replace `class Welcome` with `class TestOne` 
- Remove the brace (or "curly bracket", i.e., the `}` symbol) at the last line.
- Add three new lines at the end of the file
- Replace `Console.WriteLine` with `CONSOLE.WriteLine`
- Replace `Console.WriteLine` with `Console.WRITELINE`
- Add a new line between `Console.` and `WriteLine`
- Add a new line between `WriteLine` and `(`
- Add a new line between `Write` and `Line`
- Replace  `Main()` with `Method()`
- Remove the indentation (i.e., the space between the beginning of the line and the first character of the instruction) on all lines
