You are here:

C#/About c# programing

Advertisement


Question
I want to write code for following requirements in console application using c#
--------------------------------------------------
DO YOU WANT  TO KNOW YOUR AGE?
PLEASE ENTER THE DATE OF BIRTH FOLLOWING THE ENTER KEY(IN THE FORM OF DD//MM//YY)
05.02.1990
YOUR AGE IS -----
---------------------------------------------------
User will enter the date of birth in the form of dd//mm//yy form and after subtracting today's dd//mm//yy from usre's date of birth (dd//mm///yy) console display his/her age.

I have written code but problem is-what is method for displaying today's date in the dd//mm//yy form and have to finding the difference?


Answer
Well there are a couple of ways to tackle this. You could have the user enter the day, the month, and the year into three seperate inputs, and then form the string yourself (this is the most user friendly/secure way). You could use a combination of the Substr() function of the String class to check to see if each two digit number is followed by a /. You will want to check out the DateTime object and perhaps use that to subtract the date, and then output it using DateTime.Format(); The information is available here; http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx

C#

All Answers


Answers by Expert:


Ask Experts

Volunteer


Daniel Fredriksen

Expertise

Questions about programming in C#, Syntax, Constructs, Semantics, SQL, Common Language Infrastructure (CLI), Managed Code, Intermediate Language (IL), Metadata, Object Oriented Programming, Software Engineering, Systems Analysis & Design, SDLC, Methods, Variables, References, Scope, Resources, Classes, Libraries, Interfaces, Components, Libraries, .NET, COM, Garbage Collection, etc.

Experience

Thirteen years experience as a computer programmer with six years experience consulting on various information technology matters to include cybersecurity. Six years experience consultanting for the U.S. Military and business clients, to include physical and information security consulting. Veteran of Operation Iraqi Freedom III, and Operation Enduring Freedom VII

Organizations
American Society for Industrial Security (ASIS) International Foundation for Protection Officers (IFPO) National Association of Investigative Specialists (NAIS) NY Army National Guard

Education/Credentials
Pursuing Doctorate in Information Technology (University of Phoenix) Pursuing Doctorate in Intelligence Management (Henley-Putnam University) C# Certification (Brainbench) Certified Protection Officer (IFPO) Associate in Science LA, AOF in Computer Science/Protective Services (Excelsior College)

©2012 About.com, a part of The New York Times Company. All rights reserved.