EDIT: Sorry if this seem a little obvious/simple, I tried finding an answer but I'm not sure how to word it correctly
I've been studying a little C# and I'm having some trouble with getting my head around instantiated new objects, where the constructor and the class type are different. So a regular object would be instantiated by:
Object obj = new Object();
That's pretty obvious, but since I've been studying interfaces I've come across some syntax like follows:
interface ISaveable {
string Save();
}
public class Catalog : ISaveable {
string Save() {
return "Catalog Save";
}
string ISaveable.Save(){
return "ISaveable Save";
}
}
And then the tutorial went on to do something along the lines of this:
Catalog c1 = new Catalog();
So I know here a new instance of the catalog class is being instantiated, however I can't for the life of me figure out this next line:
ISaveable c2 = new Catalog();
Now the actual code itself is no problem (I understand explicit and implicit implementation of interfaces etc.), but it's just the part about the actual instantiation of the above object c2. Why is the class type (ISaveable) different to the constructor ( new Catalog() )?
Any explanation will be very appreciated!