Close

c# – An intro to Arrays and Generics

Here are some terminologies: Arrays: This is a object variable, that is designed to store a collection of object-variable. Each object variable is stored in numbered containers (i.e. they are indexed), with the first container starting at number 0. Generics: these are like arrays, but they can only store builtin c# variables, i.e. variables that […]

Read More

c# – Arrays

Arrays are used to store a a group of items as a collection: [csharp] using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Arrays { class Program { static void Main(string[] args) { // Here we are creating an array called "vowels", that can house up to 5 items. string[] vowels = new […]

Read More

c# – Generics: Lists

Arrays have a big limitation is that you cant extend the array to hold more than the number items it was originally defined to hold. As a result a lot of people uses “lists” as an alternative. You can find the lists class in the following namespace: System.Collections.Generic Here is the link for the “generic” […]

Read More

c# – Generics: Queue

Queues are like lists, but works on the basis of first-in, first-out, here’s an example: [csharp] using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Queue { class Program { static void Main(string[] args) { // here we create an empty queue that we define to only hold // integers. Queue<int=> MyQueue = […]

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 Queue { class Program { […]

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[] args) { // here we […]

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; namespace ExceptionExample { class Program […]

Read More

c# – Intro to Exceptions

Sometimes you might have a block of “dangerous code” in your program. These are code that could fail. When these blocks of “dangerous codes” fail, it will stop the program straight, and won’t attempt to carry on any further, and instead it will just output an error message. However sometimes you might want your program […]

Read More

c# – The Interface

We previously came across the concept of inheritance, which is where a child class (implicitly) inherits the properties and methods from it’s parent class. However what if you don’t want a class to inherit methods and properties, but we do want class to have certain members (properties and methods) with particular names. That’s where “interfaces” […]

Read More

c# – Abstract Classes

When you organise your code into parent and child classes (in order to fully utilize the concept of inheritance in order to cut down code duplication), you may end up with parent classes, that are just there for the purpose of holding base-class code. The class itself isn’t needed for instantiating objects. These types of […]

Read More