Close

c# – Switch statements (aka case statements)

Here is a quick switch statement demo: [csharp] using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SwitchStatementDemo { class Program { static void Main(string[] args) { Console.Write("enter a number: "); //the parse converts the input into an integer. int input = int.Parse(Console.ReadLine()); switch (input) { case 1: // this is how to […]

Read More

c# – Embed variables in a string using the substition technique

Previously in the boolean chapter we saw: [csharp] using System; class BooleanDemo { static void Main() { bool myFirstBoolean = 3 + 2 == 5; Console.WriteLine(myFirstBoolean.ToString()); bool mySecondBoolean = 3 + 2 => 5; Console.WriteLine(mySecondBoolean.ToString()); // Here we use the ‘and’, "&&" operator bool BothAreTrue = myFirstBoolean && mySecondBoolean ; Console.WriteLine("Are both true: " + […]

Read More

c# – Booleans

booleans are variables that hold true or false.   [csharp] using System; class BooleanDemo { static void Main() { bool myFirstBoolean = 3 + 2 == 5; Console.WriteLine(myFirstBoolean.ToString()); bool mySecondBoolean = 3 + 2 => 5; Console.WriteLine(mySecondBoolean.ToString()); // Here we use the ‘and’, "&&" operator bool BothAreTrue = myFirstBoolean && mySecondBoolean ; Console.WriteLine("Are both true: […]

Read More

c# – An overview of commonly used variables

Previously we looked at why variables are categorized as either “value types”, or “reference types” (primarily for memory reasons). Now lets take a look at these variables in action, starting with the string variable. String variables We already encountered string variables when we created the “message” string variable in our hello world program. You can […]

Read More

c# – What are Variables Types

A variable is essentially a container that’s used for storing data. This container has a name assigned to it. In programming, this name is used to refer to the variable’s content. In c# there are actually three high-level types of variables: Value Types Reference types Pointer types (we will ignore this for now, but will […]

Read More