Good afternoon, there is a List with several columns of data, here is an example
public static List<(double date, double profit)> data_good_proffit =
new List<(double date, double profit)>();
how to write to search using the Contains method in the Profit column?
data_good_proffit.Contains();
so writes an error
CodePudding user response:
Contain
will do if you want to find out the entire tuple, e.g.
// Do we have date == 5.0 and profit == 7.1?
bool result = data_good_proffit.Contains((5.0, 7.1));
If you want to check for profit
only and ignore the date
try to query with a help of Linq:
using System.Linq;
...
// Do we have any item with profit == 7.1?
bool result = data_good_proffit.Any(item => item.profit == 7.1);
please, not that you have a list of tuples, with no separate columns existing.