Hi...
Well... Reflection may do it for you, but it's not very intersting, because
in development time you don't know the properties, methods etc.
The best thing to do is a Abstract Class, something like a Costumer, that
implements the commom properties to the costumers...
Then you may implement a specialized class for the other type of costumers:
public abstract class Costumer
{
protected string Name {get;set;}
protected string Address {get; set;}
//other commom properties
//commom methods
}
public class CostumerX : Costumer
{
protected string Telephone {get; set;}
protected string SoftwareNumber {get; set;}
}
public class CostumerY : Costumer
{
protected string Hobbies {get; set;}
protected string Website {get; set;}
}
Now you can do it:
Costumer costumerX = new CosctumerX();
costumerX.Name = "Some name";
costumerX.Telephone = "12345";
But you cannot do:
costumerX.Hobbies, because Hobbies is a property of the CostumerY class.
Regards,
Vinicius Quaiato.
On Fri, Feb 27, 2009 at 7:04 AM, Belisario <[email protected]> wrote:
>
> Hello everybody!
>
> I'm a VB.Net beginner.
> I'm trying to understand if it's possible to create a class with a
> method in it to add new properties to this class.
>
> Let me put it better: I am building a customer class. This would have
> some base fixed properties like "Name" or "Address", but I would like
> to give the user the possibility to build his own free custom
> property, like "Telephone Number" and "Software version" for Mr. Smith
> and "Customer hobbies" and "Website" for Mr. Brown.
> So:
>
> Mr. Smith's Customer Object properties:
> "Name"
> "Address"
> "Telephone Number"
> "Software version"
>
> Mr. Brown Customer Object properties:
> "Name"
> "Address"
> "Customer hobbies"
> "Website"
>
> I searched a lot through the net but I still can't understand if this
> is possible and how. I heard about something called "reflection", but
> I am still not sure if I am searching the right way...
>
> Could you please help me on this point or show me other possible ways
> to overcome the issue?
>
> Thank you very much!
>