简体   繁体   中英

Translate this code from C# to VB.NET

How do you convert the following C# code to VB.NET?

private static readonly ICollection<string>
    _skipHeaders = new[]
        {
            "Connection",
            "Keep-Alive",
            "Accept",
            "Host",
            "User-Agent",
            "Content-Length",
            "Content-Type",
            "Accept-Encoding",
            "Authorization",
            "Referer",
            ProxyMethodHeader,
            ProxyAuthorizationHeader,
            ProxyAcceptHeader,
            ProxyAgentHeader,
            ProxyQueryHeader
        };

The following will work for vb9

Private Shared _skipHeaders as ICollection(Of String) = New String() { _
  "Connection", _
  "Keep-Alive", _ 
  ...  }
Private Shared ReadOnly _skipHeaders As ICollection(Of String) = New () 
{"Connection", "Keep-Alive", "Accept", "Host", "User-Agent", "Content-Length", "Content-Type", "Accept-Encoding", "Authorization", "Referer", ProxyMethodHeader, ProxyAuthorizationHeader, ProxyAcceptHeader, ProxyAgentHeader, ProxyQueryHeader}

I upvoted JaredPar's answer because it's correct. For future reference, there's a great conversion tool at http://www.developerfusion.com/tools/convert/csharp-to-vb/ .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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