With a sample code I have below, Im trying to understand what is the exact difference between "=" operator vs "==" in the where clause?
I have list of items with a property of IsActive. When I do this:
GetAllItemsFromCache
-- just returns List<Item>
2 of them are IsActive
False
, 8 of them are True
// this return 10 items whereas 2 of them were `IsActive` property was set to `false`in the initial list, but now IsActive seems true for all the items
bool someFlag = true;
var result = GetAllItemsFromCache().Where(i => i.IsActive = someFlag).ToList();
// this return nothing - In the list 2 of them were `IsActive` property was set to `false`
bool someFlag = false;
var result = GetAllItemsFromCache().Where(i => i.IsActive = someFlag).ToList();
// using regular == operator just returns as expected based on the flag. No question here
bool someFlag = false;
var result = GetAllItemsFromCache().Where(i => i.IsActive == someFlag).ToList();
Can someone explain? (or if you share a link so I can read details)