Link to home
Start Free TrialLog in
Avatar of AWestEng
AWestEngFlag for Sweden

asked on

Convert Dictionary foreach search to Linq

Hi

is it possible to convert this code to use Linq instead?
private bool Exists(string name)
        {
            foreach (ClientData p in _clients.Keys)
            {
                if (p.Id.Equals(name, StringComparison.OrdinalIgnoreCase))
                {
                    return true;
                }
            }
 
            return false;
        }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of abel
abel
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of AWestEng

ASKER

sorry FernandoSoto:, I accepted able's reply you where posting yours, I'm sorry m8..
Not a problem, that happens. Have a great day.  ;=)
If you want, you can request reopen and split. I won't object to that. FernandoSoto put in quite some effort, though I believe his solution is about the same as what I showed (though slightly more verbose perhaps).
No need to do that, it is really not a problem.  ;=)
Thx guys,, perfect job
Thanks AWestEng and abel.  ;=)
No!  Thank you guys! Thx for always put your own time into others problem and help out.
I really appreciate it . :)
you're welcome, both, always around to help (almost)  :)