R
rbDeveloper
Hope this isn't too far off subject...
The following was recently proposed (not by me) as a question for
prospective job candidates. "Review the method below and say what gets
returned." Apparently, this came straight off some website for "C# Interview
Questions." The answer they gave is "tryfinally". The reality, this won't
even compile because you can't return from a finally block. Personally, I
wouldn't put a return anywhere inside a try/catch/finally block just for
readability reasons.
I'm curious, are people finding such contrived questions on interviews?
Thanks,
Randy
static private string test1()
{
string s = string.Empty;
try
{
s += "try";
return s;
}
catch
{
s += "catch";
}
finally
{
s += "finally";
return s;
}
return s;
}
The following was recently proposed (not by me) as a question for
prospective job candidates. "Review the method below and say what gets
returned." Apparently, this came straight off some website for "C# Interview
Questions." The answer they gave is "tryfinally". The reality, this won't
even compile because you can't return from a finally block. Personally, I
wouldn't put a return anywhere inside a try/catch/finally block just for
readability reasons.
I'm curious, are people finding such contrived questions on interviews?
Thanks,
Randy
static private string test1()
{
string s = string.Empty;
try
{
s += "try";
return s;
}
catch
{
s += "catch";
}
finally
{
s += "finally";
return s;
}
return s;
}