TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
raf maester
NA
5
1.5k
How to convert Shared sub (vb.net) to C#?
Apr 12 2021 1:50 PM
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);
}
}
}
Reply
Answers (
3
)
Circle's centre follows parabolic trajectory
Application using windows forms in c#, file, structure