简体   繁体   English

等效的vb.net代码

[英]Equivalent vb.net code

i am new to asp.net.Can you post an equivalent vb.net code following the C#.net code. 我是asp.net的新手。您可以在C#.net代码之后发布等效的vb.net代码吗? Thanks 谢谢

public string  getSecureCookie(HttpRequest Request)
{
    HttpCookie secureCookie = Request.Cookies["Test"];
        if(secureCookie!=null)
    {
        return secureCookie.ToString();
    }
    else
        {
            return "";
    }
}

Run through the code translator available at http://www.carlosag.net/Tools/CodeTranslator/ 浏览http://www.carlosag.net/Tools/CodeTranslator/上的代码转换器

Public Function getSecureCookie(ByVal Request As HttpRequest) As String
    Dim secureCookie As HttpCookie = Request.Cookies("Test")
    If (Not (secureCookie) Is Nothing) Then
        Return secureCookie.ToString
    Else
        Return ""
    End If
End Function

Might want to use If secureCookie IsNot Nothing instead, though. 可能想改用If secureCookie IsNot Nothing But the translator does work. 但是翻译确实可以。

Try this 尝试这个

Public Function getSecureCookie(ByVal request as HttpRequest) As String
  Dim cookie = request.Cookies("Test")
  if cookie IsNot Nothing Then
    return cookie.ToString()
  Else
    return ""
  End If
End Function

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM