There is no solution that allows that: the return value from the finally block will always be used, simply because it is
always executed at the end of the try block regardless of what else happens within it: catch or not.
The simplest solution is just to not set
name
within the finally block:
private string GetName()
{
string name = "";
try
{
name = "This is my name";
}
catch (Exception)
{
name = "Error";
}
finally
{
}
return name;
}