Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Count How Many Days Old You are ?
WhatsApp
Shridhar Sharma
Jun 03
2015
2
k
0
0
DateTimetxt.rar
DateTime d1 =
new
DateTime();
DateTime d2 =
new
DateTime();
Console.WriteLine(
"Enter today's date in year/month/date"
);
d2 = Convert.ToDateTime(Console.ReadLine()).Date;
Console.WriteLine(
"enter your birthdate"
);
d1 = Convert.ToDateTime(Console.ReadLine()).Date;
if
(d2 > d1)
{
TimeSpan difference = d2 - d1;
// using (StreamWriter sw = new StreamWriter("E:\\Shridhar\\Birthday.txt")) ;
Console.WriteLine(
"You are "
+ difference.Days +
" days old. "
);
}
else
{
Console.WriteLine(
"today's date should be greater than your birthdate ."
);
}
Console.ReadKey();
C#
datetime
.Net
Up Next
Count How Many Days Old You are ?