469,299 Members | 2,069 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,299 developers. It's quick & easy.

Create Property on the fly

Hello,

Is it possible to add a property to a class on the fly? If yes, How can I do
this or where can I find an exemple?

Thank you

Marc R.
Nov 30 '06 #1
6 2135
Marc,

A (non static) class is a *template* that you use at design time, so what do
you mean with "on the fly"?

Cor

"Marc Robitaille" <marc.marie AT globetrotter.net.delschreef in bericht
news:Oa**************@TK2MSFTNGP02.phx.gbl...
Hello,

Is it possible to add a property to a class on the fly? If yes, How can I
do this or where can I find an exemple?

Thank you

Marc R.

Nov 30 '06 #2
Hello Cor,

In my project, I need to create an Enum of a list of files and create a
property from my enum at runtime. I have already found a peace of code to
creates Enum on the fly at runtime but nothing on properties

Thank you

"Cor Ligthert [MVP]" <no************@planet.nla écrit dans le message de
news: uG**************@TK2MSFTNGP05.phx.gbl...
Marc,

A (non static) class is a *template* that you use at design time, so what
do you mean with "on the fly"?

Cor

"Marc Robitaille" <marc.marie AT globetrotter.net.delschreef in bericht
news:Oa**************@TK2MSFTNGP02.phx.gbl...
>Hello,

Is it possible to add a property to a class on the fly? If yes, How can I
do this or where can I find an exemple?

Thank you

Marc R.


Nov 30 '06 #3
I suspect you don't *need* to create the enum of files but if you told us
more about what you are trying to do we might be able to suggest a better
way.

Nov 30 '06 #4
Marc Robitaille wrote:
In my project, I need to create an Enum of a list of files and create a
property from my enum at runtime.
[IMHO] No; you don't.

There are plenty of ways of doing .. whatever it is you're actually
trying to achieve .. without creating new Types at run-time. Whilst
it's /ever/ so clever that VB can do this, it's a Pain in the Proverbial
to try and work out what happened when it [inevitably] goes wrong.

Since you're working with files, I'd suggest a property that is indexed
by /file name/ as a starting point, probably derived from some sort of
collection base class so that you can iterate through them.

HTH,
Phill W.
Nov 30 '06 #5
Yes, I was thinking "Dictionary" ;)

"Phill W." <p-.-a-.-w-a-r-d@o-p-e-n-.-a-c-.-u-kwrote in message
news:ek**********@south.jnrs.ja.net...
Marc Robitaille wrote:
>In my project, I need to create an Enum of a list of files and create a
property from my enum at runtime.

[IMHO] No; you don't.

There are plenty of ways of doing .. whatever it is you're actually trying
to achieve .. without creating new Types at run-time. Whilst it's /ever/
so clever that VB can do this, it's a Pain in the Proverbial to try and
work out what happened when it [inevitably] goes wrong.

Since you're working with files, I'd suggest a property that is indexed by
/file name/ as a starting point, probably derived from some sort of
collection base class so that you can iterate through them.

HTH,
Phill W.

Nov 30 '06 #6

Marc Robitaille wrote:
Hello Cor,

In my project, I need to create an Enum of a list of files and create a
property from my enum at runtime. I have already found a peace of code to
creates Enum on the fly at runtime but nothing on properties
Just curious, where did you find that code? I don't really need it but
it sounds like a neat trick, and I'd like to see how it works. ;)

Nov 30 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Boniek | last post: by
5 posts views Thread by ypul | last post: by
37 posts views Thread by Steven Bethard | last post: by
18 posts views Thread by Steven Bethard | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Geralt96 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.