Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class DateRange
- {
- public DateTime From { get; private set; }
- public DateTime To { get; private set; }
- public DateRange(DateTime from, DateTime to)
- {
- // Self-validating
- if (from > to)
- {
- throw new ArgumentException("From date cannot be after To date.");
- }
- From = from;
- To = to;
- }
- // Behavior-rich
- public bool Includes(DateTime date)
- {
- return date >= From && date <= To;
- }
- public bool OverlapsWith(DateRange other)
- {
- return From <= other.To && To >= other.From;
- }
- // ... (Equals i GetHashCode metode za jednakost po vrednostima)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement