I have a public void listarProduto()
method. It needs to have all the input information by the user. My problem is it's time to call this method within a MessageBox()
on the form for the message to appear.
I have a public void listarProduto()
method. It needs to have all the input information by the user. My problem is it's time to call this method within a MessageBox()
on the form for the message to appear.
It is not possible, at least if I understand the placement. If the method does something but does not result in anything it can not be used as an expression in a place that expects some information, return method void
can only be called as statement .
Or you should modify the method to return what you want to use in MessageBox()
or you should get other information somewhere if it is available.
Probably there is an error in this method, because if it lists something even, that is, if it is something screen, it already does what it should and does not need to pass this to MessageBox()
, probably should have a 'MessageBox () within it showing what you want.
On the other hand, the most likely thing is that it only delivers the product data to do what it wants, then it should return an object or a string , ie it should not handle the screen, are different responsibilities.
The way you're talking, I think it would be the opposite, the way would be to call the method and execute the MessageBox()
call within that method.