Passing in an object as an out parameter
c#, reference
Solution
This MSDN document describes the "out" keyword: http://msdn.microsoft.com/en-us/library/t3c3bfhx(v=vs.80).aspx Before you call the isValid() method, you need to declare the output object:
void FindingObjectType(String str)
{
Object obj;
if(isValid(str, out obj)
//process
}
Problem
I have a method that checks for validity of an object with respect to my program (some algorithm). The object is created(parsed) from a string that is passed in. The logic is: ``` bool isValid(String str, out Object obj) { obj = null; obj = new Object(str); //Validation happens during the object creating if(obj.Legit) //Don't mind this line :) return true; return false; } ``` And I call this validation from another class, which if this validation fails, does a different validation (same method) ``` void FindingObjectType(String str) { if(isValid(str, out ??????) //process } ``` So instead of ?????, I don't know how to pass the object. I have only 1 constructor, Object(String).