By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,876 Members | 1,239 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,876 IT Pros & Developers. It's quick & easy.

Can't inherit from System.Drawing.Image

P: n/a
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()
{
}
}
}
Jul 13 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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_krwrote in
news:Xn*************************@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() {
}
}
}
Jul 13 '06 #2

P: n/a
"J" <krazou@yahoo_co_kra écrit dans le message de news:
Xn*************************@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
Jul 13 '06 #3

P: n/a
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
"J" <krazou@yahoo_co_krwrote in message
news:Xn*************************@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_krwrote in
news:Xn*************************@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() {
}
}
}

Jul 13 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.