> The code works fine but it's always Sunday the first day of week. I
> would like to change this.
> And here is my code:
>
> int DayIndex;
> DateTime objDate=new DateTime(Year,Month,Day);
>
> //First day of week.
> int StartDayIndex=(int)objDate.DayOfWeek;
>
> //Empty array days.
> for(int i=0; i<37; i++)
> days[i]=0;
>
> for(int i=0; i<31; i++)
> {
> DayIndex=(StartDayIndex+i);
> if(i < DateTime.DaysInMonth(Year,Month))
> {
> days[DayIndex]=(i+1);
> }
> else
> {
> days[DayIndex]=0;
> }
>
> }
I don't see how the above has anything to do with the FirstDayOfWeek
property.
DateTime.DayOfWeek has nothing to do with whatever the first day of the week
is.
I don't really understand what you're trying to do here. You're filling an
array with...something. For what purpose? What is the meaning of, for
example, days[12]?
If I run the above with todays date (sept 1, 2006) I would get the
following:
days[0]=0
days[1]=0
days[2]=0
days[3]=0
days[4]=0
days[5]=1
days[6]=2
days[7]=3
days[8]=4
days[9]=5
days[10]=6
....
days[29]=25
days[30]=26
days[31]=27
days[32]=28
days[33]=29
days[34]=30
days[35]=0
days[36]=0
How are you building a calendar from this? What would you like the array to
look like for todays date (sept 1, 2006)?
/claes
|