create class with dynamic properties

  • Thread starter Thread starter davidw
  • Start date Start date
D

davidw

I found it seems there is a way to create a class with dynamic properties, I
don't really need define each property?

In ASP.NET, Profile is created with all profile items in web.config as its
properties, I found it has code like this:

public static SettingsPropertyCollection Properties
{
get
{
ProfileBase.InitializeStatic();
return ProfileBase.s_Properties;
}
}

I an not quite sure how it works, but in most case, I would like properties
of some of my class are controlled by code, that means I don't need define
those properties before compilation, could anyone tell me how I do that?

thanks!
 
davidw said:
I found it seems there is a way to create a class with dynamic properties,
I
don't really need define each property?

In ASP.NET, Profile is created with all profile items in web.config as its
properties, I found it has code like this:

public static SettingsPropertyCollection Properties
{
get
{
ProfileBase.InitializeStatic();
return ProfileBase.s_Properties;
}
}

I an not quite sure how it works, but in most case, I would like
properties
of some of my class are controlled by code, that means I don't need define
those properties before compilation, could anyone tell me how I do that?

I think ASP.NET requires web.config to be available during compilation.

However a Dictionary object will give you just about the effect you are
looking for.
 
Back
Top