-5

I want to fetch data from the web. For numbers, my code is working properly. But for text the function is not working. Here is my code.

 foreach (ListItem li in varListItems)
        {
            if (li.OuterText.Contains("Bedroom"))
                NoOfBedRooms = Utility.GetNumber(li.OuterText);
            else if (li.OuterText.Contains("Bathrooms"))
                NoOfBathRooms = Utility.GetNumber(li.OuterText);
            else if (li.OuterText.Contains("Floor No"))
                FloorNo = Utility.GetNumber(li.OuterText);
            else if (li.OuterText.Contains("Area"))
                Area1 = Utility.GetNumber(li.OuterText);
            else if (li.OuterText.Contains("Furnished"))
                Furnished = Utility.GetNumber(li.OuterText);
            else if (li.OuterText.Contains("Ownership"))
                Ownership = Utility.GetNumber(li.OuterText);
            else if (li.OuterText.Contains("New/Resale"))
                NewResale = Utility.GetNumber(li.OuterText);
        }

NoOfBedRooms and NoOfBathRooms contains numeric values and they are fetching properly. But other contains text, and it is not returning data.

Bob Tway
  • 9,301
  • 17
  • 80
  • 162

2 Answers2

0

For numbers it works fine. But for string it will not, becasue you are calling Utility.GetNumber which only retuuns number

NCA
  • 810
  • 1
  • 8
  • 19
  • k but any other function to call string. – illakya ramesh Apr 08 '15 at 12:47
  • What the Utility class actually for ? Please find the class implementation in your application and see whether is there any method that return string. If not please write a custom method with the same logic of GetNumber() returning a string value. – NCA Apr 08 '15 at 12:50
0

With a method name like "GetNumber", your Utility class (which you did not include in your post), one can only surmise that it will only return numbers. Therefore you are not going to get anything but numbers out of that.

Change the code to not use Utility.GetNumber when you want text.

Russ
  • 4,091
  • 21
  • 32