private void _Class() { var result = Calculator.Add(2, 4); //using static method ( Dont Need Declare an object ) var agus = new Person { Firstname = "agus", LastName = "bagus" }; //Declare Created an object ' "new" syntax use to assign place for an object in memory' agus.Introduce(); // not using static method (have to create an object first) Console.WriteLine(result); }
private void _ClassIntermediate() { /* * CLASSES : * Classes are building blocks of software applications. * A class encapsulates data (stored in fields) and behaviour (defined by methods) * An object is an instance of a class. We can create an object using the new operator. */ var person = new Person(); person.Name = "John"; // using object to call a method person.Introduce("Nanda"); var p = Person.Parse("Jancok"); // using static method, Parse method is returning a Person() Object, I dont have to create an object first p.Introduce("Nanda"); }