Close

tutorial

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 && […]

Read More

c# – Generics: Stack

Stacks are practically the same thing as Queues, but works on the basis of last-in, first-out. Here is the stack’s reference page: http://msdn.microsoft.com/en-us/library/3278tedw(v=vs.110).aspx It basically works in the opposite order of how a queue works. Here’s an example: [csharp] using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace […]

Read More

c# – Hello World

Here we are going to first show you a simple “hello world” program in the form of an exe file. When you double-click on the exe file, all that will happen is that a console terminal will open a display the message “hello world”, like this:   Step 1 -Write […]

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 ; […]

Read More

c# – Generics: Dictionary (aka hashtable)

In c#, dictionaries are the same thing as hashtables. Dictonaries are a bit like arrays where you can customise the default index numbers to something more meaningful, here’s an example: [csharp] using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Dictionary { class Program { static void Main(string[] […]

Read More

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: […]

Read More

c# – Using the “Null” object

Sometimes a method will ask for an input parameter, but that input parameter is optional. In these situation you can still trigger the method, without passing an input parameter, and instead pass in a “null” object in it’s place: [csharp] using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; […]

Read More