bool isAgeAllowed(int minAge, DateTime birthDate)
{
double age = Math.Round(System.DateTime.Now.Subtract(birthDate).TotalDays / 365.25, 2);
return (age > minAge);
}
Вызов функции:
private void button2_Click(object sender, System.EventArgs e)
{
// Example Usage
if (!isAgeAllowed(18, new DateTime(1995, 10, 27, 4, 0, 0)))
MessageBox.Show("Вы не достигли совершеннолетия!");
else
MessageBox.Show("Вы достигли совершеннолетия!");
}
0.00 (0%) 0 votes








