根据出生日期计算年龄
2015-08-06 08:53
525 查看
System.Console.Write("请输入你的出生日期:"); string inputbirth = System.Console.ReadLine(); DateTime dtBirth = Convert.ToDateTime(inputbirth); DateTime dtNow = DateTime.Now; int days = ((TimeSpan)(dtNow - dtBirth)).Days; int iyears = days / 365; string result = String.Format("您的年龄:{0}周岁", iyears); if (iyears <= 0) { int month = days / 31; int adays = days % 31; if (month > 0) result = String.Format("您的年龄:{0}月{1}天", month, adays); else result = String.Format("您的年龄:{0}天", adays); }
相关文章推荐
- 南邮 OJ 1519 H_TRC1
- php笔记07:http响应详解(禁用缓存设置和文件下载)
- mysql不重启的情况下修改参数变量
- UI05_Control
- 南邮 OJ 1516 E_TRC1
- HDU 1728--【BFS && 记录转弯次数】
- UI05_手势识别器
- NSBundle的使用
- 南邮 OJ 1512 命题风格
- 手机归属地查询-IP地址查询-身份证查询-域名备案查询--Api接口
- hdoj 2717 Catch That Cow【bfs】
- UISwitch
- codeforces 327C. Magic Five
- Matlab关联m文件与m文件关联设置
- Codeforces Round #Pi (Div. 2) C. Geometric Progression
- 深入Python(3): and、or以及and-or
- 天合汽车安全技术(张家港)有限公司
- MongoDB集群——分片
- 软件工程师职场生存技能
- UVALive 4174