finally block in C#

Sometimes , it might be necessary to define a block of code that needs to be executed regardless of the exception.

For example , you might want to close the database connection or close the file .

finally block can usually be used for this purpose.

public void Data(params int[] datum)
{
            int val = 0;
            try
            {
                foreach (var da in datum)
                {
                    val = val + da;
                }
            }
            finally
            {
                val = 0;
            }
}