Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
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
Reflection constructors
Code challenge: Integer Comparison - Overkill - Function Dictionary
asxsdxasd sd
dateTime parsing
Test
two words are anagrams
asxasxd
4 Distinct Integer Custom Code Generator
Fibonacci Series
testing