If DateTime is an object and default C# parameters can only be assigned compile-time constants, how do you provide default values for objects like DateTime?
I am trying to initialize values in a POCO with a constructor, using named parameters with default values.
DateTimecannot be used as a constant but you could make it a nullable type (DateTime?) instead.Give the
DateTime?a default value ofnull, and if it is set tonullat the start of your function, then you can initialize it to any value you want.You can call it with a named parameter like this:
And with the default parameter like this: