Close

Visual Studio

c# – The “this” keyword

Earlier we cam across the following: [csharp] using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class Employee { public string Firstname { get; set; } //Note, the above line is the shorthand way of writing the following: // // private string firstname; // here we are defining a […]

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

Read More

c# – Instantiate an object and set it’s Properties simultaneously (using the Initialization approach)

  1st Approach: Using Initialization Here we use properties (as demonstrated in the previous), but this time we set all the properties in one go, by writing them as part of the object’s actual declaration, using curly-bracket syntax: [csharp] using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class […]

Read More

c# – Delegates

What if you want the output of one method, to be treated as an input parameter for another method? i.e. you want to do something similar to linux bash piping in the world of c#, but instead of piping from one command, to another, you are piping from one method […]

Read More

c# – Instantiate an object and set it’s Properties simultaneously (using the Constructors approach)

2nd Approach – Using the “Constructor” Constructor is a special type of method that is present in all classes, even if you don’t explicitly define it in the class itself. Constructors are used for creating an instance of the object…. this basically means that whenever you declare a new instance […]

Read More

c# – Inheritence in Action

Lets say we have a supermarket and it sells a different types of fruits, then you could create a class for each type of fruit: The above will output: [csharp] using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace InheritenceInAction { class Program { static void Main(string[] args) […]

Read More