c# - Nullable bool or bool with default value in action? -
perhaps small question im curious.
what favored?
in controllers action, when passing arguments, when , how should used?
public actionresult action(bool abool = false) or
public actionresult action(bool? anullablebool) i tend use defualt-value bit more clear , eassier check, thinking wrong?
the 2 not equivalent. in first example, caller must specify true or false, if not, false used.
in second line, caller may provide true, or false, or null. need decide how handle null. that's third value can get. plus caller can not omit it. needs pass value.
Comments
Post a Comment