Home All Groups Group Topic Archive Search About

Can't inherit from System.Drawing.Image

Author
13 Jul 2006 6:58 AM
J
I tried to inherit 'Shot' class from 'Image' class, only to fail.
It gives me the CS0122 error, which says that it can't access
'System.Drawing.Image.Image()'.

What am I missing?



using System;

namespace Vol
{
    public class Shot : System.Drawing.Image
    {
        public Shot()  // CS0122 - can't access System.Drawing.Image.Image()
        {
        }
    }
}

Author
13 Jul 2006 7:44 AM
J
Somebody told me that the 'Image' class sets the c'tor as internal, so only
the classes inside System.Drawing dll assembly can inherit from 'Image',
such as 'Bitmap'.

If this is true, there is no way to inherit from System.Drawing.Image?

Sorry if the question is not clear, it's because I'm a beginner with C#. 
:-)



J <krazou@yahoo_co_kr> wrote in
Show quoteHide quote
news:Xns97FFA2821C50Bkrazouyahoo@207.46.248.16:

> I tried to inherit 'Shot' class from 'Image' class, only to fail.
> It gives me the CS0122 error, which says that it can't access
> 'System.Drawing.Image.Image()'.
>
> What am I missing?
>
>
>
> using System;
>
> namespace Vol
> {
>      public class Shot : System.Drawing.Image
>      {
>           public Shot()  // CS0122 - can't access
>           System.Drawing.Image.Image() {
>           }
>      }
> }
Are all your drivers up to date? click for free checkup

Author
13 Jul 2006 10:05 AM
chanmm
No you can't inherit from it. I tried and can't even compile. Err: has no
constructors defined

Probably you can use it with need to inherit it.

chanmm


Show quoteHide quote
"J" <krazou@yahoo_co_kr> wrote in message
news:Xns97FFAA5074B1Dkrazouyahoo@207.46.248.16...
> Somebody told me that the 'Image' class sets the c'tor as internal, so
> only
> the classes inside System.Drawing dll assembly can inherit from 'Image',
> such as 'Bitmap'.
>
> If this is true, there is no way to inherit from System.Drawing.Image?
>
> Sorry if the question is not clear, it's because I'm a beginner with C#.
> :-)
>
>
>
> J <krazou@yahoo_co_kr> wrote in
> news:Xns97FFA2821C50Bkrazouyahoo@207.46.248.16:
>
>> I tried to inherit 'Shot' class from 'Image' class, only to fail.
>> It gives me the CS0122 error, which says that it can't access
>> 'System.Drawing.Image.Image()'.
>>
>> What am I missing?
>>
>>
>>
>> using System;
>>
>> namespace Vol
>> {
>>      public class Shot : System.Drawing.Image
>>      {
>>           public Shot()  // CS0122 - can't access
>>           System.Drawing.Image.Image() {
>>           }
>>      }
>> }
>
Author
13 Jul 2006 7:54 AM
Joanna Carter [TeamB]
"J" <krazou@yahoo_co_kr> a écrit dans le message de news:
Xns97FFA2821C50Bkrazouyahoo@207.46.248.16...

|I tried to inherit 'Shot' class from 'Image' class, only to fail.
| It gives me the CS0122 error, which says that it can't access
| 'System.Drawing.Image.Image()'.
|
| What am I missing?

Image is an abstract class that is only intended to be derived from
internally.

You should write a wrapper class that holds either a Bitmap or Metafile;
both of which derive from Image.

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer

Bookmark and Share