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

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -