I wish to say:
public void Problem(DateTime optional = DateTime.MaxValue)
{
}
But the compiler complains that DateTime.MaxValue is not a compile time constant.
DateTime.MinValue is easy, just use default(DateTime)
see also "How do I default a parameter to Guid.Empty in C#?"
I do not wish to use method overloading, as the method I am trying to tame has 101 parameters!
I would substitute this for something like:
public void Problem(DateTime? optional = null)
{
DateTime dateTime = optional ?? DateTime.MaxValue
// Now use dateTime
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With