Cannot implicitly convert type 'System.DateTime' to 'string' error is rising
-
Hi, Can anyone tell me why the error is coming like "Cannot implicitly convert type 'System.DateTime' to 'string'"? When i work with the following code. Code: protected void Page_Load(object sender, EventArgs e) { Label1.Text = DateTime.Now; Label2.Text = DateTime.Now; Label3.Text = DateTime.Now; } Thanks in advance.
-
Hi, Can anyone tell me why the error is coming like "Cannot implicitly convert type 'System.DateTime' to 'string'"? When i work with the following code. Code: protected void Page_Load(object sender, EventArgs e) { Label1.Text = DateTime.Now; Label2.Text = DateTime.Now; Label3.Text = DateTime.Now; } Thanks in advance.
Because DateTime.Now is of type DateTime... Try Label1.Text = DateTime.Now.ToString(); or custom format Label1.Text = DateTime.Now.ToString("yyyy-MM-dd"); //etc...
-
Hi, Can anyone tell me why the error is coming like "Cannot implicitly convert type 'System.DateTime' to 'string'"? When i work with the following code. Code: protected void Page_Load(object sender, EventArgs e) { Label1.Text = DateTime.Now; Label2.Text = DateTime.Now; Label3.Text = DateTime.Now; } Thanks in advance.
Well, the error message is clear... :rolleyes:
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Well, the error message is clear... :rolleyes:
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]