C# Lesson 2 – Basic Input and variables

Create a new console project called BasicInput

Enter the following code inside the main function



String username declares a variable called username of type string. This will allow us to store any character on the keyboard: numbers, symbols and letters.

Example1: “Joe Bloggs”

Example2: “1234”

Example3: “”

Note: 123 + 456 = 579, However “123” + “456” = “123456”

Adding Strings together is called concatenation


username = Console.ReadLine() The input from the user is then stored in the variable user name


Console .WriteLine( "Hello " + username) Adds the word “hello” to the string “username”