How do I calculate someone's age in C#?

0
=
0
+
0
No specific Bitcoin Bounty has been announced by author. Still, anyone could send Bitcoin Tips to those who provide a good answer.
0

Given a DateTime representing a person's birthday, how do I calculate their age?

Tags: ,

1 Answer

1
=
0
=
$0
Internet users could send Bitcoin Tips to you if they like your answer!

You could try this code:

DateTime now = DateTime.Today;
int age = now.Year - bday.Year;
if (now < bday.AddYears(age)) age--;
SEND BITCOIN TIPS
0

Too many commands? Learning new syntax?

FavScripts.com is a free tool to save your favorite scripts and commands, then quickly find and copy-paste your commands with just few clicks.

Boost your productivity with FavScripts.com!

Post Answer