c# – What you should already know
You should already be familiar with the following: Variables Conditonal construct, e.g. If statements Conditional Operators, regular expressions wild cards
"Building Immutable Cloud Infrastructure one container at a time!"
You should already be familiar with the following: Variables Conditonal construct, e.g. If statements Conditional Operators, regular expressions wild cards
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 && […]
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 […]
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 […]
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 ; […]
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[] […]
It is always good practice to insert comments into your code so that you (as well as others) can understand what your code is doing. You can place a single line comment after a line of code, or on a line of it’s own using the “//” notation. If you […]
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: […]
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; […]
When programming it is essential to organize and structure your code, otherwise it will become unwieldy to work with. c# offer a number of ways to structure and and organize our code using: methods classes namespaces Methods are used for storing blocks of codes and each method is designed to […]