Hello I am newbie to C# and I'm trying to figure out the "implicit conversion" operation. I have a question about it:
class Animal { }
class Monkey : Animal { }
Monkey m = new Monkey();
Animal a = m;
m.GetType()
[Submission#165+Monkey]
a.GetType()
[Submission#165+Monkey]
Monkey m2 = a;// this calls - Compiler Error CS0266. Cannot implicitly convert type 'Animal' to 'Monkey'. An explicit
conversion exists (are you missing a cast?)
I don't understand - if last code line throws an error CS0266, why does GetType method returns that "a" variable has a type "Monkey". If "a" variable is Animal how to find it out? By what method?