Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8379913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:18:55+00:00 2026-06-09T16:18:55+00:00

With this code: Dictionary<DateTime, double> FlowInformation = new Dictionary<DateTime, double>(); foreach (DateTime key in

  • 0

With this code:

Dictionary<DateTime, double> FlowInformation = new Dictionary<DateTime, double>();

foreach (DateTime key in FlowInformation)
{
    if (initialialrec != 0)
    {
        if (FlowInformation[key] > initialialrec)
            flow = key.ToShortDateString() + " " + key.ToShortTimeString() + "+";

        if (FlowInformation[key] < initialialrec)
            flow = key.ToShortDateString() + " " + key.ToShortTimeString()+"-";

        initialialrec = FlowInformation[key];
        file.WriteLine(flow);
    }

    FlowInformation.Clear();                    
}

I get a compilation error:

Strategy\theFlowStrategy.cs Cannot convert type 'System.Collections.Generic.KeyValuePair' to 'System.DateTime'   

How can I iterate though this collection?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T16:18:57+00:00Added an answer on June 9, 2026 at 4:18 pm

    A Generic dictionary is a list of KeyValuePair items.

    To loop on the keys (as you are trying to do), then loop on FlowInformation.Keys. You can also loop on the values directly using FlowInformation.Values.

    The other thing you could do is to use KeyValuePair as your iteration variable type. That will save you having to do FlowInformation[key] to find out which value corresponds to your key, as the value will be in the .Value property of the iteration variable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This code works, but is inefficient because it double-lookups the ignored dictionary. How can
Consider this code: // Dictionary created. Dictionary<string, string> objDic = new Dictionary<string, string>(); string
Consider this code: private readonly Dictionary<Type, Component> _components = new Dictionary<Type, Component>(); public Component
I have this piece of code : Dictionary<string, object> tempDict = new Dictionary<string, object>();
Initial conditions: DateTime moment string key double value somewhere across the code i want
I have this Dictionary Dictionary<Guid, DateTime> myDic = new Dictionary<Guid, DateTime>(); What is the
Answer solved in edit below I had this piece of code Dictionary<Merchant, int> remaingCards
In my application I use the ShinyBlue.xaml resource dictionary which has this code for
Using this standard code: NSMutableDictionary *params = [NSMutableDictionary dictionary]; [params setObject:image forKey:@photo]; [params setObject:text
this is my code private void sendToClient(Dictionary<string, string> reportDic) { Response.Clear(); Response.BufferOutput = false;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.