I have a string array and a for loop to add items to list.
Here is my code:
//customers table :
// Firstname, Lastname, Age, BrowserName, Date
string[] browsers = {"chrome", "Firefox", "Edge"}
var users = db.customers.ToList();
list<string> names = new List<string>();
for(var i = 0; i < browsers.lenght; i++) {
names.Add(users.where(x => x.BrowserName == browsers[i]).FirstName);
}
Is there any way to use Linq method or something else instead of for
?