Link to home
Start Free TrialLog in
Avatar of Tom Knowlton
Tom KnowltonFlag for United States of America

asked on

C# use LINQ syntax to loop through a Dictionary

Speaking as a total LINQ newbie:

Is there a more "LINQ" ish way to interate over list of integers and fill the dictionary?

The commented code works ...  I am just looking for a more LINQ like syntax / solution.

Please provide code in C#....

 public IDictionary<int, string> ReturnIntStringCollection(ICollection<int> IntegerCollection)
        {
            //Dictionary<int, string> DictionaryOfIntsAndStrings = new Dictionary<int, string>();

            //foreach (int tempInt in IntegerCollection)
            //{
            //    NumPlusKeyword npkw = new NumPlusKeyword();
            //    npkw = IntegerIsValid(tempInt);
            //    if (npkw.NumValid)
            //    {
            //        DictionaryOfIntsAndStrings.Add(npkw.Number, npkw.KeyWord);
            //    }
            //}

            //return DictionaryOfIntsAndStrings;
        }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of it_saige
it_saige
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