There is a list of candidates.
candid: {12,14,16,19,25,64,78}
Code :
for (int i = 0; i < candid.Count; i++)
{
var searchTerm = candid[i].ToString();
var searchItems = searchTerm.ToCharArray().ToString();
foreach (Tran b in transactions)
{
string[] temp = new string[b.itemsUtilities.Count];
int j = 0;
foreach (ItemUtility c in b.itemsUtilities)
{
temp[j] = c.item.ToString();
j = j + 1;
}
if (searchItems.All(a => temp.Contains(a)))
arraye[i] = arraye[i] + (b.transactionUtility);
}
}
I receive the following error:
'string[]' does not contain a definition for 'Contains' and the best extension method overload 'Queryable.Contains(IQueryable, char)' requires a receiver of type 'IQueryable'
If code changed from : var searchItems = searchTerm.ToCharArray().ToString();
To : var searchItems = searchTerm.split();
This error is fixed, But this split command does not separate numbers.
searchTerm.ToCharArray().ToString(). it will always return"System.Char[]"no matter whatsearchTermwas.using system.Linqare you missing thisstring[] searchItemsbut ended getting astring searchItemsbecause of the.ToCharArray().ToString()