Click here to Skip to main content
15,891,316 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Why the error is giving in DateTime

ERROR - The DateTiem is a namespace but it is used like Type

CA code is given below

C#
private void Form1_Load(object sender, EventArgs e)
       {
           string strDate = "01/10/1981";
           DateTime MyBirthDayDate = Convert.ToDateTime(strDate);
           int Age = CalculateYorAge(MyBirthDayDate);
       }
       public static int CalculateYorAge(DateTime birthDaydate)
       {
           int yearsAge = DateTime.Now.Year - birthDaydate.Year;
           if (DateTime.Now.Month < birthDaydate.Month || (DateTime.Now.Month == birthDaydate.Month && DateTime.Now.Day < birthDaydate.Day))                yearsAge--; return yearsAge;
       }
Posted

Do you have any namespace with "DateTime" name? Just try and go to definition of DateTime in any of the lines of code you have and you should be able to figure out the error.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900