[Winforms .NET 4.0]
I want to be able to call a method and either return a bool or an object. Or anythign that can satisfy my example.
Example:
Method query the database. If the returned row is null i want the calling method to know this in order to call another check method. If the query returns a row with data i should return the data object.
One way i thought is to use the out keyword. Make the method return bool and initialize the returning object prior to calling the method.
After the method runs i could check if true and then manipuate the object…
Is this a good way?
Why not just return a
nullreference then? Would you ever wantnullto mean anything else? (For example, would you ever want to represent that a null value has been found, with a different meaning to the value not being found in the first place?)