I have been recently studying upcasting and downcasting in c#. I understand that upcasting refers to conversion from a derived class to a base class. However, when i see a practical example of upcasting (like below), i get confused.
public class Shape
{
...
}
public class Circle : Shape
{
...
}
Circle circle = new Circle();
Shape shape = new Shape();
// Converting an object into its base class reference
shape = circle
If we are converting circle into its base class reference, shouldn't it be like
circle = shape
Sorry if it sounds too amateur. This is because I have always seen expressions in the following format:
int x = 3; // means assign 3 to variable x.
So I am just confused why circle is on the right hand side and not on the left hand side. Please advise. Consider me a beginner.