how to derive class from generic Image class

  • Thread starter Thread starter Marcin Kowalewski
  • Start date Start date
M

Marcin Kowalewski

Hi I've got a stupid problem with code below :

using System;
using System.Drawing;
....
public class CsrcImage :Image
{
public CsrcImage()
{
//
}
}
....

Compiler return error:
'System.Drawing.Image.Image()' is inaccessible due to its protection level

OK I know that Image is an Abstract class with no constructor, but it must
be magic trick to derive new class from Image.
For example Bitmap class is derived from Image (but is sealed unfortunately)

Please help me
Marcin
 
Marcin,
OK I know that Image is an Abstract class with no constructor, but it must
be magic trick to derive new class from Image.
Actually the constructor of Image is declared as internal, which means that
Bitmap which is defined in the same assembly (System.Drawing) as Image is
able to derive from it.

CsrcImage which is defined outside of the System.Drawing assembly cannot
access the internal constructor of Image, hence it cannot derive from it.

Its a somewhat clever OO trick to allow an object model in an assembly that
others cannot participate in.

Hope this helps
Jay
 
Thanks Jay,

does it mean that there is NO WAY to derive my class from Image??

Marcin
 
It also indicates to me that they did not think their design of the Image
class through very well. If they had truly generalized the Image class,
then they would not fear others who wanted to develop their own image
format.
 
Back
Top