I have the following code:
foreach (Logs log in _logsDutyStatusChange)
{
string driverid = log.did;
}
How would I only add distinct driver ID's to the driverid string?
Thanks
This should work (without linq):
Hashset<string> alreadyEncountered = new Hashset<string>();
foreach (Logs log in _logsDutyStatusChange)
{
if(alreadyEncountered.Contains(log.did))
{
continue;
}
string driverid = log.did;
alreadyEncountered.Add(driverid);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With