Click here to Skip to main content
15,895,142 members
Home / Discussions / C#
   

C#

 
GeneralRe: DateTime, DayOfWeek in range comparison Pin
#realJSOP2-May-08 8:15
mve#realJSOP2-May-08 8:15 
GeneralRe: DateTime, DayOfWeek in range comparison Pin
PIEBALDconsult2-May-08 8:46
mvePIEBALDconsult2-May-08 8:46 
AnswerRe: DateTime, DayOfWeek in range comparison Pin
PIEBALDconsult2-May-08 7:28
mvePIEBALDconsult2-May-08 7:28 
GeneralRe: DateTime, DayOfWeek in range comparison Pin
#realJSOP2-May-08 7:43
mve#realJSOP2-May-08 7:43 
AnswerRe: DateTime, DayOfWeek in range comparison Pin
#realJSOP2-May-08 8:10
mve#realJSOP2-May-08 8:10 
GeneralRe: DateTime, DayOfWeek in range comparison Pin
PIEBALDconsult2-May-08 9:13
mvePIEBALDconsult2-May-08 9:13 
GeneralRe: DateTime, DayOfWeek in range comparison Pin
PIEBALDconsult2-May-08 18:55
mvePIEBALDconsult2-May-08 18:55 
GeneralRe: DateTime, DayOfWeek in range comparison Pin
#realJSOP3-May-08 0:26
mve#realJSOP3-May-08 0:26 
Maybe even two questions...

1) Given the following:

DayOfWeek startDay = DayOfWeek.Thursday;
DayOfWeek endDay = DayOfWeek.Monday;
DayOfWeek currentDay = DayOfWeek.Wednesday;


Write a C# publicly accessible function that determines whether or not the day falls between startDay and endDay. The function should work for any combination of startDay/endDay values, and should return a boolean value (true if in range, false if not in range).

Answer:

public bool DateInRange(DayOfWeek currentDay, DayOfWeek startDay, DayofWeek endDay)
{
    return (currentDay >= startDay || currentDay <= endDay);
}



2) Given the function above, change the function so that the class encapsulating it does not have to be instantiated in order to use the function.

Answer:

public static bool DateInRange(DayOfWeek currentDay, DayOfWeek startDay, DayofWeek endDay)
{
    return (currentDay >= startDay || currentDay <= endDay);
}



"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001


GeneralRe: DateTime, DayOfWeek in range comparison Pin
PIEBALDconsult3-May-08 5:09
mvePIEBALDconsult3-May-08 5:09 
GeneralRe: DateTime, DayOfWeek in range comparison Pin
#realJSOP4-May-08 4:02
mve#realJSOP4-May-08 4:02 
GeneralRe: DateTime, DayOfWeek in range comparison Pin
PIEBALDconsult4-May-08 5:34
mvePIEBALDconsult4-May-08 5:34 
QuestionKeypress event Pin
D i x y2-May-08 2:38
D i x y2-May-08 2:38 
AnswerRe: Keypress event Pin
John Ad2-May-08 3:54
John Ad2-May-08 3:54 
AnswerRe: Keypress event Pin
PIEBALDconsult2-May-08 8:22
mvePIEBALDconsult2-May-08 8:22 
GeneralRe: Keypress event Pin
Adeel Chaudhry2-May-08 11:19
Adeel Chaudhry2-May-08 11:19 
GeneralRe: Keypress event Pin
PIEBALDconsult2-May-08 15:26
mvePIEBALDconsult2-May-08 15:26 
GeneralRe: Keypress event Pin
Adeel Chaudhry3-May-08 0:24
Adeel Chaudhry3-May-08 0:24 
QuestionExport Issue Pin
MumbleB2-May-08 2:30
MumbleB2-May-08 2:30 
AnswerRe: Export Issue Pin
Judah Gabriel Himango2-May-08 5:37
sponsorJudah Gabriel Himango2-May-08 5:37 
GeneralRe: Export Issue Pin
MumbleB2-May-08 5:45
MumbleB2-May-08 5:45 
AnswerRe: Export Issue Pin
Big Daddy Farang2-May-08 5:47
Big Daddy Farang2-May-08 5:47 
GeneralRe: Export Issue Pin
MumbleB2-May-08 5:54
MumbleB2-May-08 5:54 
GeneralRe: Export Issue Pin
Big Daddy Farang2-May-08 6:48
Big Daddy Farang2-May-08 6:48 
GeneralRe: Export Issue Pin
MumbleB2-May-08 10:36
MumbleB2-May-08 10:36 
AnswerRe: Export Issue Pin
MumbleB2-May-08 10:47
MumbleB2-May-08 10:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.