F21SC FAQ: C# programming
This page discusses frequently asked questions in the context of the course on Systems Programming and Scripting.
How do I start Visual Studio?
Go to the Windows menu (bottom left) and select "Microsoft Visual Studio 2015" in the pop-up menu. Then select the C# instance of Visual Studio.
Where can I download a student version of Visual Studio to use on my laptop?
Search for "Microsoft Imagine and follow the instructions there. You'll most likely have to email ithelp@hw.ac.uk to confirm that you are a student at Heriot-Watt.
Which version of Visual Studio should I download?
I suggest to download Visual Studio 2015, which matches the version in the lab. It supports all language features and tools that we will cover in the course. If you use a more recent version, such as Visual Studio 2017, test early on that you can transfer a project from your laptop to a lab-machine.
How do I get access from outside HW to protected internal web pages?
See this page. In general, check the MACS CS FAQ.
How to install Mono on Ubuntu 20.04
The core installation of Mono on Ubuntu 20.04 requires just 2 install commands below, one for the bytecode interpreter, and one for the C# compiler.
# for mono command: bytecode interpreter sudo apt install mono-runtime # test that mono is available which mono # for mcs command: C# compiler sudo apt install mono-mcs # test that mcs is available which mcs
You may install the .NET SDK to give you full libraries etc. Beware this might use up quite a bit more of disk space.
# optional: an SDK for .NET platform sudo snap install dotnet-sdk --classic
These packages are only needed when you work with larger projects, across several files and using more C# libraries. If you stay with Mono, you probably want to look into this before starting CW1.
# nuget package manager sudo apt-get -y install nuget # xbuild build manager sudo apt-get install mono-xbuild # nunit for unit testing in C# sudo apt-get install nunit-console
Mono-develop is an IDE that tries to behave like Visual Studio. There are other alternatives for IDEs as well, such as Visual Studio Code or riders. Pick the one you feel most comfortable with.
# TODO: mono-develop as an IDE!? # CHECK: https://www.monodevelop.com/download/ # For latest Mono: https://www.mono-project.com/download/stable/
How to use a docker container
A docker container is a useful way to isolate the installation of some software, that you are just trying out, from the main installation that you have on your laptop. It needs the docker infrastructure to be installed (docker.io on the host machine).
You can start a new docker container, that runs Ubuntu 20.04 inside, and that shares the directory ~/docker-share from your home directory like this:
sudo docker run -i -t -e DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v $HOME/.Xauthority:/$HOME/.Xauthority -v $HOME/docker-share:$HOME/docker-share --net=host ubuntu:20.04
Now, inside the docker container, where you'll see a fresh root shell, update the package index and install basic tools
apt-get update apt-get install nano bc sudo wget
Then, create a new account and a new group and switch to this account.
groupadd -g 1702 lecturer; useradd -u 1702 -g 1702 -G sudo -s /bin/bash -m lecturer; chown lecturer:lecturer /home/lecturer; passwd lecturer su -l lecturer
You can now work within this account, picking up files from your shared directory ~/docker-share, and compile/run as shown in the Live coding screencasts.
Leave the container by pressing CTRL-D. To restart your container again, with the things installed from the last session do
docker start -ai container-name
To get the container-name type sudo docker ps -a and check the name for the most recently created container.
Where do I start with the exercises?
Go to the folder with sample sources for C# and look-up the sample programs from the start. You can cut-and-paste the code into an empty file, best in a new "Console Application" project. Look through the code to make sure that you understand what is going.
I can't click on the above "sample sources for C#" link. What shall I do?
Use Firefox (or Chrome) instead of Internet Explorer.
Which kind of application should I select?
When you start a new project, you can choose from a fairly long list of projects, each of which will get you a different template to start with. For the early exercises select a "Console application".
How do I compile a program?
Select the "Build" option in the menu-bar of Visual Studio.
How do I run a program?
Select the "Debug" option and choose "Run without debugging". Make sure to use this option! If you choose "Run with debugging" the terminal showing the results will disappear after execution.
How can I force Visual Studio to keep showing the terminal window?
Put a System.Console.ReadLine(); at the end of your program.
How can I provide command-line arguments to the program?
If you write a Main function with arguments that reads these arguments
from the command-line, you need select the option
Project (top row) ->
One of the exercises asks to read input from the console. How can I do that?
In general, use the documentation available in Visual Studio to browse the list of available methods. The System namespace covers the methods for I/O. In this case, you will need the System.Console.ReadLine(); method.
How do I found out more about docu-tags?
Documentation tags, such as <summary> should be used to document the functionality of a method. To find out more visit this page on the MS Developer Network.
F21SC FAQ: Python
For any issues about local setup, eg. connect to Linux machines from outside the university or where to put files for your home page, check the MACS CS FAQ first.
How do I install Python on my laptop?
Follow these instructions. On an Ubuntu 16.04 machine it should be sufficient to do:
sudo apt-get install python3
How do I install the Python libraries necessary for the exercises and coursework?
Most of the libraries should come with Python 3.5. You may additionally have to install these libraries: numpy, scipy, matplotlib, pandas. On an Ubuntu 16.04 machine you can install all of these in one go using the line below:
sudo apt-get install python3-matplotlib python3-numpy python3-scipy python3-pandas
Where do I get the Python examples from the lecture?
It is linked from the main Course Information Page: download all Python samples
How do get started with doing the Python exercises?
As first steps with Python, go to the Python Tutor web page and do some introductory exercises, using their single-stepping support.
Then get examples from the sample sources section for Python, do these examples in a Python shell, and try modifying them slightly.
How do I start IDLE on the Linux Lab machines?
Either launch it from the "Programming" menu or type idle3 on the command line.
How to use the IDLE IDE for Python
See this HOWTO guide.
Lecturers:
- Hans-Wolfgang Loidl (HWL)
Links :
- Vision page
- Course Descriptor
-
- Linux Introduction
-
- Software for download:
Related Courses: