Last post Oct 27, 2014 02:16 AM by demoninside9
Aug 01, 2014 07:06 AM|demoninside9|LINK
My web application was working perfectly. There was no issue with that.
Suddenly I was need to add a reference of System.Web.Helpers.ddl in my project. After adding this in my project I am getting an error
Cannot implicitly convert type 'System.DateTime' to 'var' on this line var date = DateTime.Now.AddYears(i);
before this it was working perfectly, I didn't made any change in my code.
protected void Bind_Year()
DataTable dt = new DataTable();
for (int i = -2; i < 4; i++)
var date = DateTime.Now.AddYears(i);
var year = date.Year;
DropDownList3.DataSource = dt;
catch (Exception ex)
Aug 01, 2014 07:13 AM|twice|LINK
Have you tried using DateTime instead of var? Maybe the compiler can't infer it. Possibly see this regarding TryParse: http://stackoverflow.com/a/4498258/2145778
Oct 27, 2014 02:16 AM|demoninside9|LINK
Sorry, that was my mistake. Actually there is a CLASS file in my App_Code folder named, var.
Now I have deleted it and the error is gone now.