Starting by the easiest one, number 2:
In that case, you're creating an instance of Square new Square(4.5f)
because Square, which could be a Class or Struct defines a constructor signature with a float as parameter.
Square()
being a struct (Structs are light-weight objects, also a bit different from classes), all the public fields has to be initialized in its constructor which has parameters, otherwise the compiler will throw a compiler error if you don't initialize the public fields. however, structs has a implicitly parameterless constructor defined which could be used.
The compiler provides a default, parameterless constructor signature if none, only if none constructor is defined (It only applies on classes).
To brief it, if you don't have any other constructor overload, you'll have to instantiate that object passing a float as argument. In that case I assume its a class. If it was a struct
, as I said, Structs has a implicitly parameterless constructor defined so the below would be valid.
Polygon polygon = new Square();
Now lets go back to the first question:
This one is related to inheritance and polymorphism.
In C# a class can inherit from a single class and many interfaces, not more and struct can only inherit interfaces.
As C# only allows a class to inherit from a single class, in other hand it allows you to have nested inheritance: class A : B : C : D and so on.
Polymorphism infers that a class can take many forms. It works in the basis that a derived class has all the features it's base class.
In C# the usage of public member are determined statically (compiter time rather at runtime) so when a derived object takes the form of its base object, it only can access the member its base defines. Also in the case of using a base in a method signature as parameter, it could receive different implementations of itself.
I'd suggest you to read this book: C# 6.0 Pocket Reference, by Joseph Albahari & Ben Albahari
Sorry if I complicated the things :)