This part of the code doesn't make sense:
string[] matchID = zteBbhRecords.Cast<iztebbh>().Select(zteBbh => (zteBbh.CombinedMaster as ICombinedMaster).CellId.ToString()).GroupBy(item => item).Where(items => items.Count() > 1).Select(item => item.Key).Distinct().ToArray();
if (matchID.Length > 0)
{
zteBbhRecords.Cast<iztebbh>().Select(zteBbh => (zteBbh.CombinedMaster as ICombinedMaster).CellId.ToString()).GroupBy(item => item).Where(items => items.Count() > 1).Select(item => item.Key).Distinct().ToArray();
}
</iztebbh></iztebbh>
The body of the if statement accomplishes
NOTHING.
It re-constructs the same thing as
matchID
but then
drops it on the floor, never to be seen again.
So what do you really want to do?
Also, there are two things wrong with the catch part of the try-catch-finally:
1. If you want the exception caught to continue up the execution stack for further handling, then just use:
catch (Exception exception)
{
throw;
}
explicitly giving the caught exception in the throw treats it as a new exception instead of continuing the same exception (different stack context)
2.
Never catch
an exception just to
throw
it. It isn't necessary to have a
catch
in order to have a
finally
.