vb.net中的DateValue()函数在c#中相当于哪个方法啊我改的是这段vb代码,要改成c#的,大家可以帮我改一下
Private Sub count()
Dim cie As HttpCookie, newguest As Boolean = False
cie = Request.cookies("rwfj")
If cie is nothing Then
newguest = True
Else
If cie("name") <> "guest" Then newguest = True
End If
Dim ds As DataSet
ds = New DataSet()
ds.ReadXml(Server.MapPath("data/count.xml"))
If DateValue(ds.Tables(0).Rows(0)(4)) <> DateValue(Date.Now) Then
ds.Tables(0).Rows(0)(0) = 0
ds.Tables(0).Rows(0)(1) = 0
End If
If newguest = True Then
cie = New HttpCookie("rwfj")
cie.Values.Add("name", "guest")
Response.AppendCookie(cie)
ds.Tables(0).Rows(0)(1) = CInt(ds.Tables(0).Rows(0)(1)) + 1
ds.Tables(0).Rows(0)(3) = CInt(ds.Tables(0).Rows(0)(3)) + 1
End If
ds.Tables(0).Rows(0)(4) = Date.Now
ds.AcceptChanges()
ds.WriteXml(Server.MapPath("data/count.xml"))
ds.Clear()
ds.Dispose()
End Sub
Private Sub count()
Dim cie As HttpCookie, newguest As Boolean = False
cie = Request.cookies("rwfj")
If cie is nothing Then
newguest = True
Else
If cie("name") <> "guest" Then newguest = True
End If
Dim ds As DataSet
ds = New DataSet()
ds.ReadXml(Server.MapPath("data/count.xml"))
If DateValue(ds.Tables(0).Rows(0)(4)) <> DateValue(Date.Now) Then
ds.Tables(0).Rows(0)(0) = 0
ds.Tables(0).Rows(0)(1) = 0
End If
If newguest = True Then
cie = New HttpCookie("rwfj")
cie.Values.Add("name", "guest")
Response.AppendCookie(cie)
ds.Tables(0).Rows(0)(1) = CInt(ds.Tables(0).Rows(0)(1)) + 1
ds.Tables(0).Rows(0)(3) = CInt(ds.Tables(0).Rows(0)(3)) + 1
End If
ds.Tables(0).Rows(0)(4) = Date.Now
ds.AcceptChanges()
ds.WriteXml(Server.MapPath("data/count.xml"))
ds.Clear()
ds.Dispose()
End Sub
DateTime dt=new DateTime(1969,2,12);
dt=dt.Date;
{
HttpCookie cie;
bool newguest=false;
cie=Request.Cookies["rwfj"];
if(cie == null)
{
newguest=true;
}
else
{
if(cie["name"] != "guest")
{
newguest=true;
}
}
DataSet ds=new DataSet();
DateTime dTime;
ds.ReadXml(Server.MapPath("data/count.xml"));
dTime=Convert.ToDateTime(ds.Tables[0].Rows[0][4].ToString());
if(dTime.Date!=DateTime.Now.Date)
{
ds.Tables[0].Rows[0][0]=0;
ds.Tables[0].Rows[0][1]=0;
}
if(newguest)
{
cie=new HttpCookie("rwfj");
cie.Values.Add("name", "guest");
Response.AppendCookie(cie);
ds.Tables[0].Rows[0][1]=Int32.Parse(ds.Tables[0].Rows[0][1].ToString())+1;
ds.Tables[0].Rows[0][3]=Int32.Parse(ds.Tables[0].Rows[0][3].ToString())+1;
}
ds.Tables[0].Rows[0][4]=DateTime.Now;
ds.AcceptChanges();
ds.WriteXml(Server.MapPath("data/count.xml"));
ds.Clear();
ds.Dispose();
}