Solution: Voter Registration Validator

Review the implementation of throwing and catching standard exceptions with guaranteed cleanup.

Solution: Voter Registration Validator

Review the implementation of throwing and catching standard exceptions with guaranteed cleanup.
C# 14.0
int applicantAge = -5;
try
{
VerifyVoterEligibility(applicantAge);
}
catch (ArgumentException ex)
{
Console.WriteLine(ex.Message);
}
finally
{
Console.WriteLine("Verification process finished.");
}
// --- Helper Method ---
void VerifyVoterEligibility(int age)
{
if (age < 0)
{
throw new ArgumentException("Age cannot be negative.");
}
if (age >= 18)
{
Console.WriteLine("Eligible to vote.");
}
else
{
Console.WriteLine("Not eligible to vote.");
}
}