473,406 Members | 2,620 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,406 software developers and data experts.

Class with different properties

Hi all,

How do I aproach this.
I need to have a class that has different popeties based on a givien value
eg

if the company value >35
then myclass should have theses two properties
bigvalue
lagecompany
someproperty
else the properties should be
smalvalue
someproperty

Thanks
Robert

Jan 11 '08 #1
4 1167
What is the reason for this? Can't you just simply selectively show
those values in the UI?

You cannot change the actual properties that the class itself has -
but you could have two classes inherited from a common base-class. Not
necessarily helpful here, though.

If this relates to serialization (xml etc) then you can provide "bool
ShouldSerialize{PropertyName}()" methods for each property, to
indicate if they should be written.

For UI / binding scenarios, it is possible to change the
PropertyDescriptor set at runtime (by implementing
ICustomTypeDescriptor, ITypedList or TypeDescriptionProvider), but
before going into much detail, I'd love to know what you are trying to
do - there are probably *far* simpler ways of doing it!

As an example, if this relates to PropertyGrid, then you could mark
the properties with two sets of attributes, and use this in the
BrowsableAttributes filter.

Marc
Jan 11 '08 #2
"Robert Bravery" <me@u.comwrote in message
news:C7**********************************@microsof t.com...
Hi all,

How do I aproach this.
I need to have a class that has different popeties based on a givien value
eg

if the company value >35
then myclass should have theses two properties
bigvalue
lagecompany
someproperty
else the properties should be
smalvalue
someproperty
Sounds to me that you should have these properties:-

Int32 value { get; set; }
bool large { get { return value 35; } }
T someproperty { get; set; }
--
Anthony Jones - MVP ASP/ASP.NET
Jan 11 '08 #3
Hi,

Could you care to explain why you need something like this?

--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
"Robert Bravery" <me@u.comwrote in message
news:C7**********************************@microsof t.com...
Hi all,

How do I aproach this.
I need to have a class that has different popeties based on a givien value
eg

if the company value >35
then myclass should have theses two properties
bigvalue
lagecompany
someproperty
else the properties should be
smalvalue
someproperty

Thanks
Robert

Jan 11 '08 #4
I would do it this way:

1) create a class that has data that is common
to all of your "subsets", like someproperty

2) include an enumeration called something like "data type"

3) include a property called something like "subdata" that is an object

4) create a class with just bigvalue and largecompany (datatype = 1)

5) create a class with just smallvalue (datatype = 2)

6) when you instantiate the class from step 1, set the datatype,
instantiate the subclass that you want to use, and set the property
from #3 (subdata) = that object

Robin S.
GoldMail, Inc.
--------------------------
"Robert Bravery" <me@u.comwrote in message
news:C7**********************************@microsof t.com...
Hi all,

How do I aproach this.
I need to have a class that has different popeties based on a givien value
eg

if the company value >35
then myclass should have theses two properties
bigvalue
lagecompany
someproperty
else the properties should be
smalvalue
someproperty

Thanks
Robert
Jan 12 '08 #5

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

Similar topics

21
by: Jon Slaughter | last post by:
I have a class that is basicaly duplicated throughout several files with only members names changing according to the class name yet with virtually the exact same coding going on. e.g. class...
9
by: David A. Osborn | last post by:
I have a set of classes that each have an enumeration in them, and based on dynamic input I need to access a different enumeration. For example Three classes Class_A, Class_B, and Class_C that...
17
by: Jef Driesen | last post by:
Suppose I have a datastructure (actually it's a graph) with one template parameter (the property P for each edge and vertex): struct graph<P>; struct vertex<P>; struct edge<P>; I also have...
8
by: Per Bull Holmen | last post by:
Hey Im new to c++, so bear with me. I'm used to other OO languages, where it is possible to have class-level initialization functions, that initialize the CLASS rather than an instance of it....
26
by: nyathancha | last post by:
Hi, How Do I create an instance of a derived class from an instance of a base class, essentially wrapping up an existing base class with some additional functionality. The reason I need this is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.