Boolean to String

  • Thread starter Thread starter shapper
  • Start date Start date
S

shapper

Hello,

I am querying a XDocument as follows:

Boolean test = true;

IEnumerable<XElement> test1 = _albums.Root.Elements("Album").Where(a
=> a.Element("Active").Value == test.ToString());

IEnumerable<XElement> test2 = _albums.Root.Elements("Album").Where(a
=> a.Element("Active").Value == "true");

The first one where I use test.ToString() I get an empty enumeration.

On the second one where I use "true" I get 4 items.

What am I missing?

Thanks,
Miguel
 
I am querying a XDocument as follows:

Boolean test = true;

IEnumerable<XElement> test1 = _albums.Root.Elements("Album").Where(a
=> a.Element("Active").Value == test.ToString());

IEnumerable<XElement> test2 = _albums.Root.Elements("Album").Where(a
=> a.Element("Active").Value == "true");

The first one where I use test.ToString() I get an empty enumeration.

On the second one where I use "true" I get 4 items.

What am I missing?

Maybe that test.ToString() returns "True" not "true".

Arne
 
Maybe that test.ToString() returns "True" not "true".

Arne

Yes that is correct. I solved it ...

The problem was that when saving to the XML file it was saved as
"true".
But when I compare the ToString() generates "True".

Thanks,
Miguel
 
Back
Top