Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Help Re: DateTime and DayofWeek - Increasing DayofWeek Value

Help Re: DateTime and DayofWeek - Increasing DayofWeek Value

Scheduled Pinned Locked Moved C#
tutorialhelpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    roman_s
    wrote on last edited by
    #1

    So I have a dictionary with DayofWeek and Int. I need to find out how to populate the Dictionary then with the Days and and integer increase. for example right now I create a dictionary: Dictionary<int,DayOfWeek> dicFindDates = new Dictionary<int,DayOfWeek>(); then I get the day of week it is for example today is "Thursday" DayOfWeek dowStartDay = (DayOfWeek)Enum.ToObject(typeof(DayOfWeek), (int)S.StartOfWeek); then I add to the dictionary

    dicFindDates.Add(0,DayofWeek)
    while (i<6)
    {
    dicFindDates.Add(i++,DayofWeek <------ ++????)
    }

    so that I get(and can change according to date): 0, Thursday 1, Friday 2, Saturday 3, Sunday 4, Monday 5, Tuesday 6, Wednesday

    L 1 Reply Last reply
    0
    • R roman_s

      So I have a dictionary with DayofWeek and Int. I need to find out how to populate the Dictionary then with the Days and and integer increase. for example right now I create a dictionary: Dictionary<int,DayOfWeek> dicFindDates = new Dictionary<int,DayOfWeek>(); then I get the day of week it is for example today is "Thursday" DayOfWeek dowStartDay = (DayOfWeek)Enum.ToObject(typeof(DayOfWeek), (int)S.StartOfWeek); then I add to the dictionary

      dicFindDates.Add(0,DayofWeek)
      while (i<6)
      {
      dicFindDates.Add(i++,DayofWeek <------ ++????)
      }

      so that I get(and can change according to date): 0, Thursday 1, Friday 2, Saturday 3, Sunday 4, Monday 5, Tuesday 6, Wednesday

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi, (DayOfWeek)i should do it. [Added] Which also implies you don't really need a dictionary at all... [/Added] BTW: I recommend you use a for loop, rather than an auto-increment in the middle of a statement. And you can handle all seven days in the same way, no need to treat 0 separately. FWIW: I have some goodies about DateTime in this article[^]. :)

      Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


      I only read formatted code with indentation, so please use PRE tags for code snippets.


      I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).


      modified on Thursday, May 20, 2010 2:41 PM

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups