locked
Help with converting VB to C# RRS feed

  • Question

  • User1909694338 posted

    Hello,

    can anyone help me convert this to C#?:

    if (HttpContext.Current.User.Identity.IsAuthenticated)
    {
        string MyPage = Strings.LCase(Strings.Left
            (System.IO.Path.GetFileName(Request.ServerVariables("SCRIPT_NAME")),
            Strings.InStr(System.IO.Path.GetFileName
               (Request.ServerVariables("SCRIPT_NAME")), ".") - 1));
        Response.Write("<a href='/admin/siteadministration.aspx?page=" + MyPage +
               "'>Edit this page</a>");
    }
    Monday, March 4, 2013 5:49 AM

Answers

  • User1534498098 posted

    I guess your question is other way around.......:) i mean the question is itself the answer. The code is in C# itself. Any wayz if you need it in VB...their you go....Happy Coding....:)

    VB 

    If HttpContext.Current.User.Identity.IsAuthenticated Then
    	Dim MyPage As String = Strings.LCase(Strings.Left(System.IO.Path.GetFileName(Request.ServerVariables("SCRIPT_NAME")), Strings.InStr(System.IO.Path.GetFileName(Request.ServerVariables("SCRIPT_NAME")), ".") - 1))
    	Response.Write("<a href='/admin/siteadministration.aspx?page=" + MyPage + "'>Edit this page</a>")
    End If
    

    C#

    if (HttpContext.Current.User.Identity.IsAuthenticated)
    {
        string MyPage = Strings.LCase(Strings.Left
            (System.IO.Path.GetFileName(Request.ServerVariables("SCRIPT_NAME")),
            Strings.InStr(System.IO.Path.GetFileName
               (Request.ServerVariables("SCRIPT_NAME")), ".") - 1));
        Response.Write("<a href='/admin/siteadministration.aspx?page=" + MyPage +
               "'>Edit this page</a>");
    }



     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, March 4, 2013 5:53 AM
  • User1186268559 posted

    This link might be a help for future :

    http://www.developerfusion.com/tools/convert/csharp-to-vb/

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, March 5, 2013 12:23 PM

All replies

  • User1534498098 posted

    I guess your question is other way around.......:) i mean the question is itself the answer. The code is in C# itself. Any wayz if you need it in VB...their you go....Happy Coding....:)

    VB 

    If HttpContext.Current.User.Identity.IsAuthenticated Then
    	Dim MyPage As String = Strings.LCase(Strings.Left(System.IO.Path.GetFileName(Request.ServerVariables("SCRIPT_NAME")), Strings.InStr(System.IO.Path.GetFileName(Request.ServerVariables("SCRIPT_NAME")), ".") - 1))
    	Response.Write("<a href='/admin/siteadministration.aspx?page=" + MyPage + "'>Edit this page</a>")
    End If
    

    C#

    if (HttpContext.Current.User.Identity.IsAuthenticated)
    {
        string MyPage = Strings.LCase(Strings.Left
            (System.IO.Path.GetFileName(Request.ServerVariables("SCRIPT_NAME")),
            Strings.InStr(System.IO.Path.GetFileName
               (Request.ServerVariables("SCRIPT_NAME")), ".") - 1));
        Response.Write("<a href='/admin/siteadministration.aspx?page=" + MyPage +
               "'>Edit this page</a>");
    }



     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, March 4, 2013 5:53 AM
  • User1909694338 posted

    Yes, I'm stupid :D Thanks a lot :)

    Monday, March 4, 2013 5:55 AM
  • User1186268559 posted

    This link might be a help for future :

    http://www.developerfusion.com/tools/convert/csharp-to-vb/

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, March 5, 2013 12:23 PM