Combine Classes?

S

SQACSharp

Hi!!

Here is two classed :

public class ClassA
{
private Color _color;
private string _description;
public Color color
{
get { return this._color; }
set { this._color = value; }
}
public string description;
{
get { return this._description; }
set { this._description = value; }
}

public ClassA(Color clr, string desc)
{
if (clr != null)
_color = clr;
if (desc!=null)
_description=desc;
}
}
public class ClassB
{
private int _anumber;
public int anumber
{
get { return this._anumber;}
set { this._anumber = value; }
}
public ClassB(int numb)
{
if (numb) != null)
_anumber = numb;
}
}

I want to include ClassB in ClassA to have all the element in ClassA
all the elements in a single class like this :
ClassA.color,ClassA.description and ClassA.anumber

Is there any way to do this?

It's for using later in a generic List<MySuperClass>

any ideas? Thanks
 
S

SQACSharp

Ok I'll try to explain my problem instead of trying to doing an
example to illustrate my needs

I need to create tons of classes that contain Html object properties
(mshtml) in order to be able to display it in a propertyGrid
ex: HtmlLink, HtmlInput, HtmlImage, ...

In all thoses classes i want to include other of my common classes
like "style" ,"parentdocument" , "..." .
In other words I want to include my "HtmlStyle" class in all thoses
classes so all my classes will have properties like backgroundColor,
borderColor

I can do :
public class HtmlLink
{
HtmlStyle _Style= new HtmlStyle();
//..
public HtmlStyle Style
{
get { return this._Style ; }
set { this._Style = value; }
}
//...
}

but when doing this I get an HtmlLink.Style.BackgroundColor property
but my background color must be like HtmlLink.BackgroundColor
instead.
 
S

SQACSharp

Thanks for your answer Peter...

I understand now that inheritance is the only option..

I decide to make things easier and simply do :
public class HtmlLink
{
HtmlStyle _Style= new HtmlStyle();
//..
public HtmlStyle Style
{
get { return this._Style ; }
set { this._Style = value; }
}
//...
}

:)
 
S

SQACSharp

By the way creating class is always a real pain for me....any usefull
links about creating complexe classes are welcome.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top