Hi
I'm new with C# and I want to convert this vb.net code to C# but i get two errors like "a namespace doesn't not contain members ..." on the line "Public Class check" and "expected classes ..." on the line "Public Shared"
Thanks for help.
Here the vb.net code:
- Imports Microsoft.VisualBasic
- Public Class check
- Public Shared Sub ok()
- Dim ok As HttpCookie
- ok = HttpContext.Current.Request.Cookies("ok")
- Try
- If Not ok.Value = "y" Then
- End If
- Catch ex As Exception
- Dim jv As String
- jv = "<script language='javascript'>" _
- & " alert('First log in.');" _
- & " window.location.href='start.aspx';" _
- & "</script>"
- HttpContext.Current.Response.Write(jv)
- End Try
- End Sub
- End Class
And here my C# code:
- using System;
- using System.Web.UI.WebControls;
- Public Class check
- {
- public static void ok()
- {
- HttpCookie ok;
- ok = HttpContext.Current.Request.Cookies("ok");
- try
- {
- if (!(ok.Value == "y"))
- {}
- }
- catch (Exception ex)
- {
- string jv;
- jv = "<script language='javascript'>" + " alert('First log in.');" + " window.location.href='start.aspx';" + "</script>";
- HttpContext.Current.Response.Write(jv);
- }
- }
- }