473,651 Members | 2,533 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

comparing objects

I have a collection of objects that I store in the session. Then I look in
that collection to see if the collection.cont ains an object. it answers
false. If I dont store that collection in the session it answers true. Is
the session somehow modifying the collection? The objects look identical.
Oct 21 '06 #1
10 1891
netnet wrote:
I have a collection of objects that I store in the session. Then I look in
that collection to see if the collection.cont ains an object. it answers
false. If I dont store that collection in the session it answers true. Is
the session somehow modifying the collection? The objects look identical.
Does your class have a proper Equals method ?

Arne
Oct 21 '06 #2
No? Could you go into more detail? Im actually using the
myCol.Contains( foo) method.

Thanks for your help.
"Arne Vajhøj" <ar**@vajhoej.d kwrote in message
news:uQg_g.2266 6$2g4.22379@duk eread09...
netnet wrote:
>I have a collection of objects that I store in the session. Then I look
in that collection to see if the collection.cont ains an object. it
answers false. If I dont store that collection in the session it answers
true. Is the session somehow modifying the collection? The objects
look identical.

Does your class have a proper Equals method ?

Arne

Oct 21 '06 #3
NetNet,
No? Could you go into more detail? Im actually using the
myCol.Contains( foo) method.
Is it possible that you give something more in detail.

I looked to this thread and it seems to me as you don't want to give any
code at all.

Cor
"netnet" <ne********@com cast.netschreef in bericht
news:uW******** ******@TK2MSFTN GP04.phx.gbl...
No? Could you go into more detail? Im actually using the
myCol.Contains( foo) method.

Thanks for your help.
"Arne Vajhøj" <ar**@vajhoej.d kwrote in message
news:uQg_g.2266 6$2g4.22379@duk eread09...
>netnet wrote:
>>I have a collection of objects that I store in the session. Then I look
in that collection to see if the collection.cont ains an object. it
answers false. If I dont store that collection in the session it
answers true. Is the session somehow modifying the collection? The
objects look identical.

Does your class have a proper Equals method ?

Arne


Oct 21 '06 #4
netnet wrote:
No? Could you go into more detail? Im actually using the
myCol.Contains( foo) method.
Contains uses Equals to see if objects are identical (and
some other ways, but Equals is probably the most relevant for you).

If you have not implemented Equals, then it uses Object Equals,
which just test if it is the same object (same location in memory) - not
if the values are the same.

To illustrate the point try and run the following code:

using System;
using System.Collecti ons.Generic;

namespace E
{
public class A
{
private string s;
public A() : this("")
{
}
public A(string s)
{
this.s = s;
}
public string S
{
get
{
return s;
}
set
{
this.s = value;
}
}
public override string ToString()
{
return s;
}
}
public class B
{
private string s;
public B() : this("")
{
}
public B(string s)
{
this.s = s;
}
public string S
{
get
{
return s;
}
set
{
s = value;
}
}
public override string ToString()
{
return s;
}
public override bool Equals(object o)
{
if (o is B)
{
if (s == ((B)o).S)
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
public override int GetHashCode()
{
return s.GetHashCode() ;
}
}
public class MainClass
{
public static void Main(string[] args)
{
List<Alst1 = new List<A>();
lst1.Add(new A("test"));
Console.WriteLi ne(lst1.Contain s(new A("test")));
List<Blst2 = new List<B>();
lst2.Add(new B("test"));
Console.WriteLi ne(lst2.Contain s(new B("test")));
}
}
}

(it is using generics, but that nothing to do with the effect)

Arne
Oct 21 '06 #5
Sorry I didnt provide more detail Cor....Heres an example of what im
doing...

//begin code to put collection in cache on SalesRegion class

public static IList getAllActiveSal esRegionsCached ()
{
if( System.Web.Http Context.Current .Cache["getAllActiveSa lesRegions"] ==
null)
resetCacheOfAll ActiveSalesRegi ons();

return
(ArrayList)Syst em.Web.HttpCont ext.Current.Cac he["getAllActiveSa lesRegions"];
}

public static void resetCacheOfAll ActiveSalesRegi ons()
{
System.Web.Http Context.Current .Cache["getAllActiveSa lesRegions"] =
SalesRegion.get AllActiveSalesR egionsQuery();
}

public static IList getAllActiveSal esRegionsUncach ed()
{
return getAllActiveSal esRegionsQuery( );
}

private static IList getAllActiveSal esRegionsQuery( )
{
string theQuery = "from SalesRegion s where s.active = true";
return Db.Session.Crea teQuery(theQuer y).List();
}

//end code cache logic....
//then this is where i use the cached collection in a code behind...

ArrayList salesRegions = SalesRegion.get AllActiveSalesR egionsCached();
ArrayList allSelectedRegi onsInActiveColl ection =
((InvoiceLineIt em)i.invoiceLin eItems[0]).getAllSalesRe gionsThatAreSel ectedInTheActiv eCollection();
for(int x=0; x<salesRegions. Count; x++)
{
if(allSelectedR egionsInActiveC ollection.Conta ins(
((SalesRegion)s alesRegions[x]) ) )
row.Add("X");
else
row.Add("");

cnt++;
}

if i use the uncached version the contains logic works fine but if i use the
cached version contains fails....

thanks again for all your help




"Arne Vajhøj" <ar**@vajhoej.d kwrote in message
news:jSp_g.2267 2$2g4.4823@duke read09...
netnet wrote:
>No? Could you go into more detail? Im actually using the
myCol.Contains (foo) method.

Contains uses Equals to see if objects are identical (and
some other ways, but Equals is probably the most relevant for you).

If you have not implemented Equals, then it uses Object Equals,
which just test if it is the same object (same location in memory) - not
if the values are the same.

To illustrate the point try and run the following code:

using System;
using System.Collecti ons.Generic;

namespace E
{
public class A
{
private string s;
public A() : this("")
{
}
public A(string s)
{
this.s = s;
}
public string S
{
get
{
return s;
}
set
{
this.s = value;
}
}
public override string ToString()
{
return s;
}
}
public class B
{
private string s;
public B() : this("")
{
}
public B(string s)
{
this.s = s;
}
public string S
{
get
{
return s;
}
set
{
s = value;
}
}
public override string ToString()
{
return s;
}
public override bool Equals(object o)
{
if (o is B)
{
if (s == ((B)o).S)
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
public override int GetHashCode()
{
return s.GetHashCode() ;
}
}
public class MainClass
{
public static void Main(string[] args)
{
List<Alst1 = new List<A>();
lst1.Add(new A("test"));
Console.WriteLi ne(lst1.Contain s(new A("test")));
List<Blst2 = new List<B>();
lst2.Add(new B("test"));
Console.WriteLi ne(lst2.Contain s(new B("test")));
}
}
}

(it is using generics, but that nothing to do with the effect)

Arne

Oct 21 '06 #6
Hi,

Originally, you wrote that you were storing the collection in the session.
The cache is quite different from the session and may actually be causing the
unexpected behavior you are observing.

After the following line is executed
ArrayList salesRegions = SalesRegion.get AllActiveSalesR egionsCached();
is salesRegions null? What is the count otherwise?

If you change the line to read as follows

ArrayList salesRegions = SalesRegions.ge tAllActiveSales RegionsUncached ();

is salesRegions null? What is the count otherwise?
--
Dave Sexton

"netnet" <ne********@com cast.netwrote in message
news:uc******** ******@TK2MSFTN GP03.phx.gbl...
Sorry I didnt provide more detail Cor....Heres an example of what im
doing...

//begin code to put collection in cache on SalesRegion class

public static IList getAllActiveSal esRegionsCached ()
{
if( System.Web.Http Context.Current .Cache["getAllActiveSa lesRegions"] ==
null)
resetCacheOfAll ActiveSalesRegi ons();

return
(ArrayList)Syst em.Web.HttpCont ext.Current.Cac he["getAllActiveSa lesRegions"];
}

public static void resetCacheOfAll ActiveSalesRegi ons()
{
System.Web.Http Context.Current .Cache["getAllActiveSa lesRegions"] =
SalesRegion.get AllActiveSalesR egionsQuery();
}

public static IList getAllActiveSal esRegionsUncach ed()
{
return getAllActiveSal esRegionsQuery( );
}

private static IList getAllActiveSal esRegionsQuery( )
{
string theQuery = "from SalesRegion s where s.active = true";
return Db.Session.Crea teQuery(theQuer y).List();
}

//end code cache logic....
//then this is where i use the cached collection in a code behind...

ArrayList salesRegions = SalesRegion.get AllActiveSalesR egionsCached();
ArrayList allSelectedRegi onsInActiveColl ection =
((InvoiceLineIt em)i.invoiceLin eItems[0]).getAllSalesRe gionsThatAreSel ectedInTheActiv eCollection();
for(int x=0; x<salesRegions. Count; x++)
{
if(allSelectedR egionsInActiveC ollection.Conta ins(
((SalesRegion)s alesRegions[x]) ) )
row.Add("X");
else
row.Add("");

cnt++;
}

if i use the uncached version the contains logic works fine but if i use the
cached version contains fails....

thanks again for all your help




"Arne Vajhøj" <ar**@vajhoej.d kwrote in message
news:jSp_g.2267 2$2g4.4823@duke read09...
>netnet wrote:
>>No? Could you go into more detail? Im actually using the
myCol.Contain s(foo) method.

Contains uses Equals to see if objects are identical (and
some other ways, but Equals is probably the most relevant for you).

If you have not implemented Equals, then it uses Object Equals,
which just test if it is the same object (same location in memory) - not
if the values are the same.

To illustrate the point try and run the following code:

using System;
using System.Collecti ons.Generic;

namespace E
{
public class A
{
private string s;
public A() : this("")
{
}
public A(string s)
{
this.s = s;
}
public string S
{
get
{
return s;
}
set
{
this.s = value;
}
}
public override string ToString()
{
return s;
}
}
public class B
{
private string s;
public B() : this("")
{
}
public B(string s)
{
this.s = s;
}
public string S
{
get
{
return s;
}
set
{
s = value;
}
}
public override string ToString()
{
return s;
}
public override bool Equals(object o)
{
if (o is B)
{
if (s == ((B)o).S)
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
public override int GetHashCode()
{
return s.GetHashCode() ;
}
}
public class MainClass
{
public static void Main(string[] args)
{
List<Alst1 = new List<A>();
lst1.Add(new A("test"));
Console.WriteL ine(lst1.Contai ns(new A("test")));
List<Blst2 = new List<B>();
lst2.Add(new B("test"));
Console.WriteL ine(lst2.Contai ns(new B("test")));
}
}
}

(it is using generics, but that nothing to do with the effect)

Arne


Oct 21 '06 #7
Hi Dave,
I tried both session and cache (in this scenario it wouldnt matter if it
was at an app or user level) and the results are the same. In both cases
below cached and uncached the result is 5 objects. They appear to be the
same objects but somehow using uncached the Contains logic works properly.
When using the cached version the objects are somehow different and Contains
always answers false.
"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
news:O8******** ******@TK2MSFTN GP05.phx.gbl...
Hi,

Originally, you wrote that you were storing the collection in the session.
The cache is quite different from the session and may actually be causing
the unexpected behavior you are observing.

After the following line is executed
>ArrayList salesRegions = SalesRegion.get AllActiveSalesR egionsCached();

is salesRegions null? What is the count otherwise?

If you change the line to read as follows

ArrayList salesRegions =
SalesRegions.ge tAllActiveSales RegionsUncached ();

is salesRegions null? What is the count otherwise?
--
Dave Sexton

"netnet" <ne********@com cast.netwrote in message
news:uc******** ******@TK2MSFTN GP03.phx.gbl...
>Sorry I didnt provide more detail Cor....Heres an example of what im
doing...

//begin code to put collection in cache on SalesRegion class

public static IList getAllActiveSal esRegionsCached ()
{
if( System.Web.Http Context.Current .Cache["getAllActiveSa lesRegions"] ==
null)
resetCacheOfAll ActiveSalesRegi ons();

return
(ArrayList)Sys tem.Web.HttpCon text.Current.Ca che["getAllActiveSa lesRegions"];
}

public static void resetCacheOfAll ActiveSalesRegi ons()
{
System.Web.Http Context.Current .Cache["getAllActiveSa lesRegions"] =
SalesRegion.ge tAllActiveSales RegionsQuery();
}

public static IList getAllActiveSal esRegionsUncach ed()
{
return getAllActiveSal esRegionsQuery( );
}

private static IList getAllActiveSal esRegionsQuery( )
{
string theQuery = "from SalesRegion s where s.active = true";
return Db.Session.Crea teQuery(theQuer y).List();
}

//end code cache logic....
//then this is where i use the cached collection in a code behind...

ArrayList salesRegions = SalesRegion.get AllActiveSalesR egionsCached();
ArrayList allSelectedRegi onsInActiveColl ection =
((InvoiceLineI tem)i.invoiceLi neItems[0]).getAllSalesRe gionsThatAreSel ectedInTheActiv eCollection();
for(int x=0; x<salesRegions. Count; x++)
{
if(allSelectedR egionsInActiveC ollection.Conta ins(
((SalesRegion) salesRegions[x]) ) )
row.Add("X");
else
row.Add("");

cnt++;
}

if i use the uncached version the contains logic works fine but if i use
the cached version contains fails....

thanks again for all your help




"Arne Vajhøj" <ar**@vajhoej.d kwrote in message
news:jSp_g.226 72$2g4.4823@duk eread09...
>>netnet wrote:
No? Could you go into more detail? Im actually using the
myCol.Contai ns(foo) method.

Contains uses Equals to see if objects are identical (and
some other ways, but Equals is probably the most relevant for you).

If you have not implemented Equals, then it uses Object Equals,
which just test if it is the same object (same location in memory) - not
if the values are the same.

To illustrate the point try and run the following code:

using System;
using System.Collecti ons.Generic;

namespace E
{
public class A
{
private string s;
public A() : this("")
{
}
public A(string s)
{
this.s = s;
}
public string S
{
get
{
return s;
}
set
{
this.s = value;
}
}
public override string ToString()
{
return s;
}
}
public class B
{
private string s;
public B() : this("")
{
}
public B(string s)
{
this.s = s;
}
public string S
{
get
{
return s;
}
set
{
s = value;
}
}
public override string ToString()
{
return s;
}
public override bool Equals(object o)
{
if (o is B)
{
if (s == ((B)o).S)
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
public override int GetHashCode()
{
return s.GetHashCode() ;
}
}
public class MainClass
{
public static void Main(string[] args)
{
List<Alst1 = new List<A>();
lst1.Add(ne w A("test"));
Console.Write Line(lst1.Conta ins(new A("test")));
List<Blst2 = new List<B>();
lst2.Add(ne w B("test"));
Console.Write Line(lst2.Conta ins(new B("test")));
}
}
}

(it is using generics, but that nothing to do with the effect)

Arne



Oct 22 '06 #8
Hi,

Then it seems that this method is the source of your problem:
>>((InvoiceLine Item)i.invoiceL ineItems[0]).getAllSalesRe gionsThatAreSel ectedInTheActiv eCollection();
I think that the method is creating a different collection of objects than the
getAllActiveSal esRegionsCached method, and you're trying to compare the
objects at the same indices in each collection via the Contains method.

As Arne already put it, the Contains method is using the Equals method, which
checks for reference equality on objects. If each collection contains
different object instances then Contains will not work in the way that you are
trying to use it.

Your best bet I think is to ensure that the
getAllSalesRegi onsThatAreSelec tedInTheActiveC ollection uses the same object
references as the getAllActiveSal esRegionsCached method.

--
Dave Sexton

"netnet" <ne********@com cast.netwrote in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
Hi Dave,
I tried both session and cache (in this scenario it wouldnt matter if it
was at an app or user level) and the results are the same. In both cases
below cached and uncached the result is 5 objects. They appear to be the
same objects but somehow using uncached the Contains logic works properly.
When using the cached version the objects are somehow different and Contains
always answers false.
"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
news:O8******** ******@TK2MSFTN GP05.phx.gbl...
>Hi,

Originally, you wrote that you were storing the collection in the session.
The cache is quite different from the session and may actually be causing
the unexpected behavior you are observing.

After the following line is executed
>>ArrayList salesRegions = SalesRegion.get AllActiveSalesR egionsCached();

is salesRegions null? What is the count otherwise?

If you change the line to read as follows

ArrayList salesRegions =
SalesRegions.g etAllActiveSale sRegionsUncache d();

is salesRegions null? What is the count otherwise?
--
Dave Sexton

"netnet" <ne********@com cast.netwrote in message
news:uc******* *******@TK2MSFT NGP03.phx.gbl.. .
>>Sorry I didnt provide more detail Cor....Heres an example of what im
doing...

//begin code to put collection in cache on SalesRegion class

public static IList getAllActiveSal esRegionsCached ()
{
if( System.Web.Http Context.Current .Cache["getAllActiveSa lesRegions"] ==
null)
resetCacheOfAll ActiveSalesRegi ons();

return
(ArrayList)Sy stem.Web.HttpCo ntext.Current.C ache["getAllActiveSa lesRegions"];
}

public static void resetCacheOfAll ActiveSalesRegi ons()
{
System.Web.Http Context.Current .Cache["getAllActiveSa lesRegions"] =
SalesRegion.g etAllActiveSale sRegionsQuery() ;
}

public static IList getAllActiveSal esRegionsUncach ed()
{
return getAllActiveSal esRegionsQuery( );
}

private static IList getAllActiveSal esRegionsQuery( )
{
string theQuery = "from SalesRegion s where s.active = true";
return Db.Session.Crea teQuery(theQuer y).List();
}

//end code cache logic....
//then this is where i use the cached collection in a code behind...

ArrayList salesRegions = SalesRegion.get AllActiveSalesR egionsCached();
ArrayList allSelectedRegi onsInActiveColl ection =
((InvoiceLine Item)i.invoiceL ineItems[0]).getAllSalesRe gionsThatAreSel ectedInTheActiv eCollection();
for(int x=0; x<salesRegions. Count; x++)
{
if(allSelectedR egionsInActiveC ollection.Conta ins(
((SalesRegion )salesRegions[x]) ) )
row.Add("X");
else
row.Add("");

cnt++;
}

if i use the uncached version the contains logic works fine but if i use
the cached version contains fails....

thanks again for all your help




"Arne Vajhøj" <ar**@vajhoej.d kwrote in message
news:jSp_g.22 672$2g4.4823@du keread09...
netnet wrote:
No? Could you go into more detail? Im actually using the
myCol.Conta ins(foo) method.

Contains uses Equals to see if objects are identical (and
some other ways, but Equals is probably the most relevant for you).

If you have not implemented Equals, then it uses Object Equals,
which just test if it is the same object (same location in memory) - not
if the values are the same.

To illustrate the point try and run the following code:

using System;
using System.Collecti ons.Generic;

namespace E
{
public class A
{
private string s;
public A() : this("")
{
}
public A(string s)
{
this.s = s;
}
public string S
{
get
{
return s;
}
set
{
this.s = value;
}
}
public override string ToString()
{
return s;
}
}
public class B
{
private string s;
public B() : this("")
{
}
public B(string s)
{
this.s = s;
}
public string S
{
get
{
return s;
}
set
{
s = value;
}
}
public override string ToString()
{
return s;
}
public override bool Equals(object o)
{
if (o is B)
{
if (s == ((B)o).S)
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
public override int GetHashCode()
{
return s.GetHashCode() ;
}
}
public class MainClass
{
public static void Main(string[] args)
{
List<Alst1 = new List<A>();
lst1.Add(n ew A("test"));
Console.Writ eLine(lst1.Cont ains(new A("test")));
List<Blst2 = new List<B>();
lst2.Add(n ew B("test"));
Console.Writ eLine(lst2.Cont ains(new B("test")));
}
}
}

(it is using generics, but that nothing to do with the effect)

Arne




Oct 22 '06 #9
NetNet,

Why do you not serialize/deserialize first.

This is a VB.Net sample however acts the same.

http://www.vb-tips.com/dbPages.aspx?...c-61641f5c8d9d

I hope this helps,
Cor

"netnet" <ne********@com cast.netschreef in bericht
news:uc******** ******@TK2MSFTN GP03.phx.gbl...
Sorry I didnt provide more detail Cor....Heres an example of what im
doing...

//begin code to put collection in cache on SalesRegion class

public static IList getAllActiveSal esRegionsCached ()
{
if( System.Web.Http Context.Current .Cache["getAllActiveSa lesRegions"] ==
null)
resetCacheOfAll ActiveSalesRegi ons();

return
(ArrayList)Syst em.Web.HttpCont ext.Current.Cac he["getAllActiveSa lesRegions"];
}

public static void resetCacheOfAll ActiveSalesRegi ons()
{
System.Web.Http Context.Current .Cache["getAllActiveSa lesRegions"] =
SalesRegion.get AllActiveSalesR egionsQuery();
}

public static IList getAllActiveSal esRegionsUncach ed()
{
return getAllActiveSal esRegionsQuery( );
}

private static IList getAllActiveSal esRegionsQuery( )
{
string theQuery = "from SalesRegion s where s.active = true";
return Db.Session.Crea teQuery(theQuer y).List();
}

//end code cache logic....
//then this is where i use the cached collection in a code behind...

ArrayList salesRegions = SalesRegion.get AllActiveSalesR egionsCached();
ArrayList allSelectedRegi onsInActiveColl ection =
((InvoiceLineIt em)i.invoiceLin eItems[0]).getAllSalesRe gionsThatAreSel ectedInTheActiv eCollection();
for(int x=0; x<salesRegions. Count; x++)
{
if(allSelectedR egionsInActiveC ollection.Conta ins(
((SalesRegion)s alesRegions[x]) ) )
row.Add("X");
else
row.Add("");

cnt++;
}

if i use the uncached version the contains logic works fine but if i use
the cached version contains fails....

thanks again for all your help




"Arne Vajhøj" <ar**@vajhoej.d kwrote in message
news:jSp_g.2267 2$2g4.4823@duke read09...
>netnet wrote:
>>No? Could you go into more detail? Im actually using the
myCol.Contain s(foo) method.

Contains uses Equals to see if objects are identical (and
some other ways, but Equals is probably the most relevant for you).

If you have not implemented Equals, then it uses Object Equals,
which just test if it is the same object (same location in memory) - not
if the values are the same.

To illustrate the point try and run the following code:

using System;
using System.Collecti ons.Generic;

namespace E
{
public class A
{
private string s;
public A() : this("")
{
}
public A(string s)
{
this.s = s;
}
public string S
{
get
{
return s;
}
set
{
this.s = value;
}
}
public override string ToString()
{
return s;
}
}
public class B
{
private string s;
public B() : this("")
{
}
public B(string s)
{
this.s = s;
}
public string S
{
get
{
return s;
}
set
{
s = value;
}
}
public override string ToString()
{
return s;
}
public override bool Equals(object o)
{
if (o is B)
{
if (s == ((B)o).S)
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
public override int GetHashCode()
{
return s.GetHashCode() ;
}
}
public class MainClass
{
public static void Main(string[] args)
{
List<Alst1 = new List<A>();
lst1.Add(new A("test"));
Console.WriteL ine(lst1.Contai ns(new A("test")));
List<Blst2 = new List<B>();
lst2.Add(new B("test"));
Console.WriteL ine(lst2.Contai ns(new B("test")));
}
}
}

(it is using generics, but that nothing to do with the effect)

Arne


Oct 23 '06 #10

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

Similar topics

5
7591
by: beliavsky | last post by:
By mistake I coded something like print ("1" > 1) and got the result "True". Comparing an integer and a string seems meaningless to me, and I would prefer to have an exception thrown. Can someone explain why Python allows comparisons between integers and strings, and how it handles those cases? Why is "1" > 1? Pychecker does not warn about the line of code above -- I wish it did.
5
4818
by: Skip Montanaro | last post by:
I'd like to compare two xml.dom.minidom objects, but the naive attempt fails: >>> import xml.dom.minidom >>> d1 = xml.dom.minidom.parse("ES.xml") >>> d2 = xml.dom.minidom.parse("ES.xml") >>> d1 == d2 False My goal is to decide whether or not I need to prompt the user to save config information at the end of a program run by generating a minidom object then
2
2034
by: Raphael Iloh | last post by:
Hi all, I'm having problems comparing array objects. Take a look at this: int array1 = new int{1}; int array2 = new int{1}; Console.Writeln(array1.Equals(array2)); One would expect the above expression to return true as both arrays are identically the same but it keeps returning false. Any info on how to solve this problem will be appreciated.
5
1797
by: George | last post by:
How do I compare the values of two objects when Option Strict is On? One of the objects is the Tag property from some control (declared as object but holding a value, e.g. an Integer or a String or a DateTime or ...). The other object is the Item property from a DataRow (declared as object but holding a value, e.g. an Integer or a String or a DateTime or ...). I can find out that they hold the same type using "If...
19
2643
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 = Color.Empty then..... or if mycolor is Color.Empty then .......
3
1301
by: Mark Denardo | last post by:
Hi I have an app that has a number of textboxes (richtextboxes to be exact) that get created dynamically and I add a few at a time to panel controls (so I can flip a group in and out when I want). So the textbox objects get added to the panel object like so: panelObj.Controls.Add(textboxObj) And then I store the panel Objects in a linked list so I can sort through them later.
5
2212
by: ma740988 | last post by:
There's a need for me to move around at specified offsets within memory. As as a result - long story short - unsigned char* is the type of choice. At issue: Consider the case ( test code ) where I'm comparing two structs. The struct test1 has information with regards to data_size and pointer to address. The struct test2 has information with regards to data_size and value. I will compare test1 and test2. For each matching data size,...
20
2142
by: Bill Pursell | last post by:
This question involves code relying on mmap, and thus is not maximally portable. Undoubtedly, many will complain that my question is not topical... I have two pointers, the first of which is mmapped to a single page. I want to determine if the second is on the page. I'd like to do: #include "platform_appropriate_definition_of_PAGESIZE.h" int compare1(const char *a, const char *b)
25
13019
by: J Caesar | last post by:
In C you can compare two pointers, p<q, as long as they come from the same array or the same malloc()ated block. Otherwise you can't. What I'd like to do is write a function int comparable(void *p, void *q) that will take any two pointers and decide whether they can be compared or not. I really can't think how to do this - any suggestions?
1
2540
by: Kevin Blount | last post by:
I'm getting data from an XML file using this method: $name = $xml->user_info->user; $nickname = $xml->user_info->user; & $age = $xml->user_info->user; $shoe_size = $xml->user_info->user;
0
8275
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8795
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...
0
8695
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8576
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7296
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
6157
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
4143
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
4281
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2696
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

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.