The most complex of the three was polymorphism. Essentially you put an instance of a child variable inside of a parent variable's instance. Only the parts of the child variable that the parent can understand (like overridden methods, or properties) are accessible.
In the process we saw some C# and got examples of class creation, child class creation, instantiating a class, writing(simple) functions and calling them.
Creating a class
public class Coder{Creating a new instance of a Class
public string Name{set;get;}
public string Language{set; get;}
public int Age{set; get;}
}
Coder p = new Coder();
using dot notation to set variables for the new instance
p.name="Alex";
p.Language="C#";
p.Age=27;
public void Code(){
Console.WriteLine("Someone is coding");
}
calling the function
Code();
No comments:
Post a Comment