Avatar of Tom Knowlton
Tom Knowlton
Flag 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

C#

Avatar of undefined
Last Comment
it_saige

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
it_saige

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck