Link to home
Start Free TrialLog in
Avatar of njgroup
njgroup

asked on

how to check value if it is between two values in linq?

hi,

I was trying to check value if it is between two values from xml file, so how to perform between "something" and "something else" using linq?


here is my try
var countries = from country in xmlDoc.Descendants("IpCountries")
                               where Dot2LongIP.ToString() between country.Element("beginningIp").Value and country.Element("endingIp").Value
                               select new
                               {
                                   hostIPAddress = country.Element("beginningIp").Value,
                                   hostName = country.Element("endingIp").Value,
                                   hostLocation = country.Element("countryCC").Value,
                                   hostBrowserType = country.Element("countryCCC").Value,
                                   hostBrowserVersion = country.Element("country").Value,
                               };

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of njgroup
njgroup

ASKER

thanks very much,

I was looking for something better than A grade to assign :))

NP. Glad to help  :)