473,657 Members | 2,531 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamic Class Property

Vic
Can a property dynamic be added to a class at runtime?
Best Regards, Vic
Nov 13 '08 #1
5 1286
"Vic" <vs*******@tele net.beschrieb
Can a property dynamic be added to a class at runtime?
No. Writing properties is a programmer's task and done before compilation.
Maybe you want to store additional values related to an object? Then have a
look at the various collections available; you could use the object as the
key.

http://msdn.microsoft.com/en-us/library/0ytkdh4s.aspx
Armin

Nov 13 '08 #2
On Nov 13, 6:53*am, "Vic" <vserge...@tele net.bewrote:
Can a property dynamic be added to a class at runtime?

Best Regards, Vic
Why would you need this?

Thanks,

Seth Rowe [MVP]
http://sethrowe.blogspot.com/
Nov 13 '08 #3
Vic
Thx for the replay.
The reason for this, dependent of a setting i need a articleobject with
between 1 and 20 salesprices properties. But if it is not possible i will
code the 20 properties.

Vic

"rowe_newsgroup s" <ro********@yah oo.comschreef in bericht
news:78******** *************** ***********@e38 g2000prn.google groups.com...
On Nov 13, 6:53 am, "Vic" <vserge...@tele net.bewrote:
Can a property dynamic be added to a class at runtime?

Best Regards, Vic
Why would you need this?

Thanks,

Seth Rowe [MVP]
http://sethrowe.blogspot.com/
Nov 13 '08 #4
It sounds like you could declare a property "SalesPrice " as List(of Decimal)

"Vic" <vs*******@tele net.bewrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
Thx for the replay.
The reason for this, dependent of a setting i need a articleobject with
between 1 and 20 salesprices properties. But if it is not possible i will
code the 20 properties.

Vic

"rowe_newsgroup s" <ro********@yah oo.comschreef in bericht
news:78******** *************** ***********@e38 g2000prn.google groups.com...
On Nov 13, 6:53 am, "Vic" <vserge...@tele net.bewrote:
>Can a property dynamic be added to a class at runtime?

Best Regards, Vic

Why would you need this?

Thanks,

Seth Rowe [MVP]
http://sethrowe.blogspot.com/
Nov 13 '08 #5
On Nov 13, 7:55 am, "Vic" <vserge...@tele net.bewrote:
The reason for this, dependent of a setting i need a articleobject with
between 1 and 20 salesprices properties. But if it is not possible i will
code the 20 properties.
Rather than code 20 properties, add a single property that is a List
(Of T) for holding your prices.

Private _salesPrices As List(Of Decimal)

Public ReadOnly Property SalesPrices As List(Of Decimal)
Public Get
Return _salesPrices
End Get
End Property

Then you can have as many or as few sales prices as you wish.

Chris
Nov 13 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
13709
by: Guy Harwood | last post by:
Hi, I have designed a textbox that inherits from the System.Windows.Forms.Textbox control. when the control is readonly the back color changes to a light blue to indicate that it is frozen. This all works well, but i would like the color to be configurable via the app.config file.
2
2560
by: Zac | last post by:
Alright anyone who has 2c throw it in... I am working through a custom xml serializer and have come upon a conundrum, given our class design. The interface implemented on the base class (base for all business entities) dictates that the implementing class expose a Dirty property (for state). The base class (that actually manages state, once for all inheritors)
4
3371
by: Richard Abraham | last post by:
I have created a new class ServiceTimer based upon the .NET System.Timers.Timer class. This has a new property CollectionIntervalMinutes which I expected to be added to the 'Behavior' section of the class properties and also to be available as a 'Dynamic' property so that I could control it from the application config file. The new property is not shown, but the properties inherited from the base class are I cannot find any reference to how...
2
1601
by: Codex Twin | last post by:
Hi I am designing a class (Q) which will contain provision for dynamic complex properties. For example, these properties could be any or all of the following complex properties: a) TeamMembers b) Pets
1
3336
by: Henke | last post by:
Hello, I have one ImageButton controls which I initialize in Page_Load and declare on class level. ImageButton save = new ImageButton(); save.ImageUrl = "save.gif" save.Click += new ImageClickEventHandler(this.save_click); This ImageButton is added to a dynamic table which is also
4
1264
by: funVB2005fun | last post by:
I am not quite sure what I am getting into but I would like to have a loop that read from a flat file to create some public properties in a class. I am going after this to try and create more general software that others could benefit from vs hardcoding things that relate only to my processes. example property that I would want to generate: The idea would be to read from a file that "AGE" is needed and that it is and Integer and then to...
2
3632
by: Luis Arvayo | last post by:
Hi, In c#, I need to dynamically create types at runtime that will consist of the following: - inherits from a given interface - will have a constructor with an int argument
3
1940
by: Dan | last post by:
Is it possible to dynamically create and populate properties? Below is my class. I would like to define properties for each of the items in my two arrays without actually defining each one. (There are over 100 in total). I would to have them set up the same as i have "form_id" below, but im not sure what the syntax to do it is (without actually typing each one). ' declare form_id private form_id
5
2047
by: cwertman | last post by:
I have a question regarding dynamic properties. I have an Object say Account --Id --Prefix --Fname --Lname --Suffix
15
10850
by: EDBrian | last post by:
My problem is this. Our clients create different fields they want to collect and we allow them build dynamic filters, reports etc... We run some TSQL to actually create the column and all works very well. We are now adding a lot more functionality to our filters and could really benefit from using the LINQ to SQL. I have experimented with the Dynamic Linq...
0
8842
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8516
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7353
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6176
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2743
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1970
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1733
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.