c# - TakeWhile() function is not working properly with Boolean value. -


according below code snippet when true value not matched in fruit array result value should hold values of array. takewhile() function not adding not matched value result list below code snippet.

 bool[] fruits = { false, false, false, false,                                    false, false};     var query = fruits.takewhile(fruit => fruit.equals(true)); 

where when string works:

string[] fruits = { "apple", "banana", "mango", "orange",                                "passionfruit", "grape" }; ienumerable<string> query = fruits.takewhile(fruit => string.compare("orange", fruit, true) != 0); 

is there way can make takewhile() function behave equal array of string when there array of bool values?

what looking is:

var query = fruits.takewhile(fruit => !fruit.equals(true)); 

it logical... take elements of fruit while are...

  • you wrote "equal true"...

  • i wrote "not equal true"

string.compare("orange", fruit, true) != 0 

means if "orange" different fruit true, else false


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -