Close

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

c# – Create a read-only property (aka a constant)

So far we have looked at 5 ways to store data in a class’s object (aka an instance) in the form of “properties”. Of which one of the recommended ways of setting values to properties, is by using the constructor method, e.g.: [csharp] using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class Employee […]

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 of a class, e.g.: Employee […]

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 Employee { public string Firstname […]

Read More