Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
How do I calculate someone's age in C#?
//Title of this code //Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { DateTime today = DateTime.Today; DateTime bday = Convert.ToDateTime("1998-09-06"); int age = today.Year - bday.Year; if (bday > today.AddYears(-age)) age--; Console.WriteLine(age); } } }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
fq
bro
Non-User input - Random Controlled - Guessing Game
Get days from two dates
c# problem
ZeroMatrix
Testing bitwise stuff
TestWall
Doubt-" 1 parameter Gen _Derive_Class inherit the 2 parameter Gen_Base_Class"
FizzBuzz C#
stackse - search stackoverflow differently
Please log in to post a comment.