If your method is called ParseTable and it fails "Parse" a "Table", then it should throw an exception. The advantage of this is that the exception can give the caller information about why it couldn't parse (html was invalid, unexpected column etc). The problem with returning null is that an unexpected nullreference exception almost never tells you the cause of the problem.
The "right" way to make a method that tries to parse a table, but happily does nothing if no result could be found is:
public bool TryParseTable(HtmlNode table, out DataTable result){
// your code...
if(success)
{
result = //the table you parsed
return true;
}
else
{
result = null;
return false;
}
}
Ok, so "result" could be null after calling this method, but at least the caller is more inclined to use an if
statement thanks to the return type and method name.