473,387 Members | 3,750 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 2254
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
2
by: Boniek | last post by:
Hi, How I can create property to binding with other objects. I want to create a data object which work as a DataTable. DataTable contains columns and dataTable is used to binding with a textBox...
2
by: Charlie | last post by:
Hi: I'm getting tired of typing get/set property definitions especially when my class has a lot of fields. Is there a way to have the VS.NET IDE declare them automatically? Thanks, Charlie
1
by: tmaster | last post by:
Within a class, can I create a property that is a listview? Here's what I tried, but it doesn't seem to work: '------------ create property to give the second form access to the first form's...
5
by: ypul | last post by:
How to use properties in webservice ? if I want to create a webservice as my middle tier and want to create public properties so that the presentation layer can assign values to the property...
37
by: Steven Bethard | last post by:
The PEP below should be mostly self explanatory. I'll try to keep the most updated versions available at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt...
18
by: Steven Bethard | last post by:
I've updated the PEP based on a number of comments on comp.lang.python. The most updated versions are still at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt...
1
by: tomjbr.32022025 | last post by:
I have started looking at the nhibernate framework, but do not really like the string based API which makes it impossible to use automatic refactoring of a property name without the risk of getting...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.