Return from two differents Types

  • Thread starter Thread starter ~toki
  • Start date Start date
T

~toki

Having,

pseudo.
public bool ! string SearhObject( string obj ) {
//Look object in a stack
//If found return it (as string,of course)
// if not found return false
}

As workaround (in this case) i create a null string that i returned.

But some return values are classes that need a valid constructor ( i need to
created ,set a "flag", blabla, only to return a "cannot find it" value)

How is resolved this situation?
 
Hi, ~toki,

You can use out parameter(s) and return true if the object was found,
otherwise false.

public bool SearchObject(string obj, out string returnString){}

Hope this helps
Martin
 
Back
Top