PC Review


Reply
Thread Tools Rate Thread

Combine Classes?

 
 
SQACSharp
Guest
Posts: n/a
 
      22nd Oct 2008
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
 
Reply With Quote
 
 
 
 
SQACSharp
Guest
Posts: n/a
 
      22nd Oct 2008
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.
 
Reply With Quote
 
SQACSharp
Guest
Posts: n/a
 
      22nd Oct 2008
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; }
}
//...
}


 
Reply With Quote
 
SQACSharp
Guest
Posts: n/a
 
      22nd Oct 2008
By the way creating class is always a real pain for me....any usefull
links about creating complexe classes are welcome.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What should I name my business classes given that LINQ data classes takes all table names? Ronald S. Cook Microsoft C# .NET 2 24th Jun 2008 02:57 AM
How i list or enumerate classes (names of classes in string format) from a certain namespace? please help. Jose Michael Meo R. Barrido Microsoft VB .NET 1 31st Dec 2004 12:13 PM
How i list or enumerate classes (names of classes in string format) from a certain namespace? please help. Jose Michael Meo R. Barrido Microsoft Dot NET 1 31st Dec 2004 12:13 PM
hot to differentiate outer classes and nested classes in late binding Daniel Microsoft Dot NET 0 20th Dec 2004 09:53 PM
Managed __value type enums and classes inside __nogc classes Edward Diener Microsoft VC .NET 0 20th Jan 2004 04:52 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:24 PM.