473,413 Members | 1,799 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,413 software developers and data experts.

value equality

Hallo NG

Does anyone have an idea how could one implement, a general routine for
value equality ?
I mean something using Reflections to get all the members of a class and
compare them recursivelly until the comparison of value type is reached. I
found in Reflections only getting of public members. Although the internal
state of an object should not be interesting for evalution of equality I
would like to make a value equality check also with values at least
protected members...

Thx for any input
Nov 16 '05 #1
2 1766
Marcel,

You can definitely use reflection to do this, but at the same time, I
don't think it is a good idea. Value equality is difficult to standardize
depending on the nature of the definition of the object (and how it relates
to what it is representing).

If you still want to go with it though, you can reflect on protected,
private, and internal members using the NonPublic value from the
BindingFlags enumeration. Usually, most overloads of the methods you use to
get fields, properties, methods, etc, etc will take a group of values from
the BindingFlags enumeration to indicate what to reflect on.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Marcel Sottnik" <so*****@removethisoption.ch> wrote in message
news:uD**************@TK2MSFTNGP15.phx.gbl...
Hallo NG

Does anyone have an idea how could one implement, a general routine for
value equality ?
I mean something using Reflections to get all the members of a class and
compare them recursivelly until the comparison of value type is reached. I
found in Reflections only getting of public members. Although the internal
state of an object should not be interesting for evalution of equality I
would like to make a value equality check also with values at least
protected members...

Thx for any input

Nov 16 '05 #2
Thanks Nicholas, you helped me.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:OR****************@TK2MSFTNGP10.phx.gbl...
Marcel,

You can definitely use reflection to do this, but at the same time, I
don't think it is a good idea. Value equality is difficult to standardize
depending on the nature of the definition of the object (and how it relates to what it is representing).

If you still want to go with it though, you can reflect on protected,
private, and internal members using the NonPublic value from the
BindingFlags enumeration. Usually, most overloads of the methods you use to get fields, properties, methods, etc, etc will take a group of values from
the BindingFlags enumeration to indicate what to reflect on.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Marcel Sottnik" <so*****@removethisoption.ch> wrote in message
news:uD**************@TK2MSFTNGP15.phx.gbl...
Hallo NG

Does anyone have an idea how could one implement, a general routine for
value equality ?
I mean something using Reflections to get all the members of a class and
compare them recursivelly until the comparison of value type is reached. I found in Reflections only getting of public members. Although the internal state of an object should not be interesting for evalution of equality I
would like to make a value equality check also with values at least
protected members...

Thx for any input


Nov 16 '05 #3

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

Similar topics

3
by: Byron | last post by:
Hi, Javascript confuses me, so I usually limit myself to Dreamweaver's built-in scripts for stuff like imageswaps. But this time I'm trying to write something very simple myself. I do most of my...
14
by: ago | last post by:
Is it possible to have a default value associated python objects? I.e. to flag an attribute in such a way that the assignment operator for the object returns the default attribute instead of the...
8
by: Tom | last post by:
Here is what I do to get a single value from my database (using Oracle ODP as example): Dim ID as Object Dim cmdTest as New OracleCommand("select ID from MyTable where key = " & KeySearch")...
19
by: Dennis | last post by:
I have a public variable in a class of type color declared as follows: public mycolor as color = color.Empty I want to check to see if the user has specified a color like; if mycolor =...
49
by: matty | last post by:
Hi, I recently got very confused (well that's my life) about the "undefined" value. I looked in the FAQ and didn't see anything about it. On...
6
by: onetitfemme | last post by:
Hi *, I have been looking for a definition or at least some workable concept of "XML equality". Searching on "XML equality" in comp.text.xml, microsoft.public.xsl and microsoft.public.xml...
37
by: spam.noam | last post by:
Hello, Guido has decided, in python-dev, that in Py3K the id-based order comparisons will be dropped. This means that, for example, "{} < " will raise a TypeError instead of the current...
3
by: toton | last post by:
Hi, I have a struct Point { int x, int y; } The points are stored in a std::vector<Pointpoints; (global vector) I want to add equality (operator == ) for the point, which will check equality...
275
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
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?
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
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
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,...
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
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...
0
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.