Hello
I'm afraid I am back again with more questions regarding converting VB.Net to C# in a ASP.Net application I am making.
Trying to convert the following:
VB Code:
Dim m As String = Request.QueryString("month") Dim y As String = Request.QueryString("year") If m Is Nothing Then m = Now.Month.ToString() If y Is Nothing Then y = Now.Year.ToString() Dim dt As New Date(y, m, 1) litTitle.Text = dt.ToString("MMMM yyy")
I can convert everything to C# without any problem, however, when trying to use the New Date, the equivalent of which in C# I have found to be new DateTime, it only excepts int as pararmeters to pass to the constructor, not string, and I cannot find a way to convert from a string to an int!
Any thoughts?
Here is what I have so far:
VB Code:
string m = Request.QueryString["month"]; string y = Request.QueryString["year"]; if (m == null) m = DateTime.Now.Month.ToString(); if (y == null) y = DateTime.Now.Year.ToString(); DateTime dt = new DateTime(y,m,1); <--- This is where I get the error!!! litTitle.Text = dt.ToString("MMMM yyy") + " Entries";
Cheers
Gary




Reply With Quote