该程序中DateTme中的错误 [英] Error in DateTme in this program

查看:47
本文介绍了该程序中DateTme中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么在DateTime中出现错误

错误-DateTiem是一个命名空间,但其使用方式类似于Type

CA代码在下面给出

Why the error is giving in DateTime

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

CA code is given below

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;
       }

推荐答案

您是否有名称为"DateTime"的命名空间?只需尝试在您拥有的任何代码行中转到DateTime的定义,您就可以找出错误.
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.


请参阅此处一次:

http://forums.asp.net/t/1505665.aspx/1 [ ^ ]

http://stackoverflow.com/questions/2046012/companyname-foo-is-a-namespace-but-is-used-like-a-type [
See here once:

http://forums.asp.net/t/1505665.aspx/1[^]

http://stackoverflow.com/questions/2046012/companyname-foo-is-a-namespace-but-is-used-like-a-type[^]


这篇关于该程序中DateTme中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆