日期:2014-05-20  浏览次数:20917 次

将vb代码转化为c#!
Public   Function   PostDate()Function   PostDate(ByVal   url   As   String,   ByVal   PostData()   As   String)   As   String
                Dim   Post   As   String   =   " "
                For   Each   s   As   String   In   PostData
                        Post   +=   s   +   "& "
                Next
                Post   =   Post.Substring(0,   Post.Length   -   1)
                Dim   html   As   String   =   " "

                Dim   encoding   As   Encoding   =   encoding.GetEncoding( "GB2312 ")
                Dim   data   As   Byte()   =   encoding.GetBytes(Post)
                Dim   myRequest   As   HttpWebRequest   =   CType(WebRequest.Create(url),   HttpWebRequest)
                myRequest.Method   =   "POST "
                myRequest.ContentType   =   "application/x-www-form-urlencoded "


                myRequest.ContentLength   =   data.Length
                Dim   newStream   As   Stream   =   myRequest.GetRequestStream()
                newStream.Write(data,   0,   data.Length)
                newStream.Close()
                Dim   resp   As   HttpWebResponse   =   CType(myRequest.GetResponse(),   HttpWebResponse)
                Dim   sr   As   StreamReader   =   New   StreamReader(resp.GetResponseStream(),   System.Text.Encoding.Default)
                html   =   sr.ReadToEnd()

                Return   html
        End   Function
请高手帮我转化一下:谢谢!

------解决方案--------------------
在网上找一个类似的C#代码不就是了吗
------解决方案--------------------
不会啊,学学!
------解决方案--------------------
下载个sharpdevelop转换,或者用VB.Net to C# Converter 1.52 转换