c# - is there any difference between return void and not return in a void function -
here's situation: call void function in program, provide messagebox ok , cancel, function encapsulated. need know user click on.
so there anyway hijack function know user choice?
or think when programmer write function, must return void when user click cancel, , didn't return when user click ok. possible can differentiated these 2 actions - return void , not return anything?
i know seems impossible, why come stackoverflow asking guys.
thank you
a function returns void has 1 return - nothing - , there no difference between returning nothing or returning void.
if you're unable change existing function , display messagebox, i'd scrap , start again if you.
what want like:
public dialogresult getdialogresult(string message, string caption) { return messagebox.show(message, caption, messageboxbuttons.okcancel); } call message want , caption, , you'll return of either dialogresult.ok or dialogresult.cancel
if more display messagebox, option check change function makes if ok clicked, example:
- if record added database if ok pressed, check record
if state of object changes, check change:
otherobject.setvalueifok(2); if (otherobject.getvalue() == 2) { // ok clicked } else { // cancel clicked }
anything else , think you're out of luck.
Comments
Post a Comment