Image class and constructor of Bitmap type?
Well I do not understand how it comes that Image class has a constructor of Bitmap type? 开发者_运维问答I mean, I can do:
Image sprite=new Bitmap(...)
Why? Its because Bitmap is derived from Image?
Yes, because Image
is abstract, but Bitmap
, which extends Image
is not. You could just as easily have your code do this instead:
Bitmap sprite = new Bitmap();
The reason why Image
is abstract is because it can also represent non-pixel-based images.
Why? Its because Bitmap is derived from Image?
Well, yeah, that's what MSDN says (assuming System.Drawing
namespace):
[SerializableAttribute]
[ComVisibleAttribute(true)]
public sealed class Bitmap : Image
But it's not the Image
class that has a Bitmap()
constructor. Since Bitmap
inherits from Image
, all instances of Bitmap
are also instances of Image
.
精彩评论