thursday

  • Thread starter Thread starter Bernie V
  • Start date Start date
B

Bernie V

Hi group,

I'm a beginner in C# (I developed 5 years in Clarion).
In Clarion it was possible to get the daynr of a week. I think in C# you get
the dayname as return.

Is it possible to get the daynr in C# also ? Or do I have to do that with
the daynames ?
And ik i have to do that with the daynames, which is the firsdt day of the
week, monday or sunday ?

I have to set 1 date on the screen, but only the thursdays.
Every week the date has to be changed automatically.

example:

this week: 22/01/2004
next week 29/01/2004
....

thx in advance for help !

grz

Bernie V
 
DateTime.DayOfWeek is what you're looking for, if by "daynr" you mean day
number.

DateTime.Now.DayOfWeek will give you the day of the week as a DayOfWeek enum
value. This value can either be tested directly , converted to string, or
converted to number. Currently the help on DayOfWeek states that Sunday =
0, Monday = 1, etc


DateTime dt = DateTime.Now;
//or DateTime dt = DateTime.Parse("1/1/2004");

if( dt.DayOfWeek == DayOfWeek.Friday)
Console.WriteLine( "It's Friday!");

Console.WriteLine( dt.DayOfWeek.ToString("G"));
Console.WriteLine( (int)dt.DayOfWeek);
 
thx !

gr

Bernie V

--
http://www.djberniev.be
Philip Rieck said:
DateTime.DayOfWeek is what you're looking for, if by "daynr" you mean day
number.

DateTime.Now.DayOfWeek will give you the day of the week as a DayOfWeek enum
value. This value can either be tested directly , converted to string, or
converted to number. Currently the help on DayOfWeek states that Sunday =
0, Monday = 1, etc


DateTime dt = DateTime.Now;
//or DateTime dt = DateTime.Parse("1/1/2004");

if( dt.DayOfWeek == DayOfWeek.Friday)
Console.WriteLine( "It's Friday!");

Console.WriteLine( dt.DayOfWeek.ToString("G"));
Console.WriteLine( (int)dt.DayOfWeek);
 
Back
Top