Sorry, but I can't provide actual code, so this maybe be difficult to understand.
I'll do the best I can.
**dset.data.arrayofData** // format of my issue
I can **GetAll from my dset** which is necessary.
The x => would equal data returned.
The problem is **data.arrayofData** is an array of data.
I need to determine if a value exist anywhere in this array for each record to determine its worth to me.
This arrayOfData would be similar to.
**arrayOfData
{
FirstName,
LastName,
Email,
}**
Let's say I'm logged in and identified by my email address. **LoggedInEmail**.
I need to search the array of this record to determine if my email address is present and the array can be 1, 2, 3, etc... in size.
**arrayOfData[0]
arrayOfData[1]
arrayOfData[2]
arrayOfData[~]**
What would I use to determine if my **LoggedInEmail** is present in **arrayOfData**?
**GetAll( x=> x.arrayOfData...)** and then what? Select? Any? Contains?
Sorry, but this is all I can provide. My hands are tied on that end.
Sorry about the formatting. I haven't been here in years.
I've reviewed some other questions, but they don't appear to apply here.
CodePudding user response:
var arrayWithData = new List<string>
{
"FirstName",
"LastName",
"Email"
};
var isInList = arrayWithData.Any(a => a.Equals("Email"));
With Any you can use a lambda to compare the value in the array to the value you are searching for. It will stop iterating when the condition is true. If the value is not in the list, then it will compare each value in the entire list to the value you give in the lambda and return false in the end because the condition was not true anywhere.