Close

sher

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# – 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