January 29, 2018
Deadlines: All three labs need to be completed before taking Lab 04.
Dependencies: The recommended order is Part 0 → lab 02 (if needed) → Part I → Part II (optional).
I apologize for the unfortunate experience of discovering the files you set up during lab 01 being removed. On top of that, I uploaded for some time the wrong example file Welcome1.zip
. Fortunately, we can fix that easily.
Since you can not store files permanently on the lab’s computer, you will have to store them either
If you chose the “remote” option (i.e., using a server), do not install a synchronization software (like Google Drive and Sync, Box’s app, etc.) on the lab computer: it will likely not work, due to University rules. Instead, create the structure / project / files on the computer during the lab, and upload them (using the web-interface) at the end of the lab. Make sure to always upload your files before unloging from the computer.
If you can’t / don’t want to find a solution during the lab, you can skip to Part I, send yourself the files over email at the end of this lab, and come back when you can.
Now that you know where to store your files, create a folder for this class, and a subfolder for each of the first three labs. Re-download Welcome1.zip
. You organization should look like the following:
└───csci1301
├── 01_lab
├── 02_lab
│ └── Welcome1.zip
└── 03_lab
Extract the archive Welcome1.zip
and suppress it.
Complete lab 02 if you did not already. Don’t forget to save your lab on your USB key or on a server once you’re done.
We will first create a new project for Visual C# using the template for “Console App (.NET Framework)”.
Welcome1.cs
): how are they different? How are they the same?Welcome1
project: how are they different? How are they the same?Build
→ Build solution
. Did the compilation succeed?Debug
→ Start without Debugging
. What happened? Compare with what was happening with the Welcome1.cs
project.Now, you will start writing your own code. We’ll start by writing a very familiar instruction to print a message.
Main
method (i.e., after the brace after static void Main(string[] args)
).Console
. The (at first sight annoying) auto-completion feature that display suggestions and messages as soon as you start typing is called Intellisense. You can read about it at https://msdn.microsoft.com/en-us/library/hcw1s69b.aspx or https://docs.microsoft.com/en-us/visualstudio/ide/using-intellisense, you’ll probably ending up using it a lot, but let’s not worry about that for now..Wri
after Console
(don’t forget the period!) and notice that Intellisense is already making good suggestions: you actually want to write WriteLine
! Either finish writing WriteLine
or select it from the menu that appeared.(
, and notice that Intellisense closed it for you, and is already displaying another message."This is my first message"
(and don’t forget the quotes).At this point, your Main
method should look like this:
Compile ( = “build”) your file. Oh, no, something went wrong! Can you fix this problem?
Once you can compile your program without error, execute ( = “run without debugging”) it.
WriteLine
and Write
?\n
? What is the purpose of \t
?\
and the "
characters, as well as two different forms of spacing.The following are two independent tasks, to widen your understanding of this class, and to prepare you for the next labs.
You may have noticed (depending on the VS version you’re using, and its configuration), during Part I, the existence of a template named “Console App (.NET Core)”. Using the following two ressources, sketch what the differences between these two frameworks are: https://docs.microsoft.com/en-us/dotnet/standard/choosing-core-framework-server, https://stackoverflow.com/q/38063837/.
At https://docs.microsoft.com/en-us/cpp/c-language/escape-sequences, it is mentionned that you can also print Unicode characters using escape sequences. Try to print some: look for codes at https://en.wikipedia.org/wiki/List_of_Unicode_characters (you need to keep only the part after U+
). You may have to add
in your main method for the printing to take place. I recommend typing this statement instead of copy / pasting it, to have a chance to read Intellisense’s descriptions.