本文介绍了将VB.NET转换为C#.Net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我试图使用这个在线工具将vb.net转换为c#.net:



但我收到此错误:

Hi,

Am trying to convert vb.net to c#.net using this online tool:
SnippetConverter
but am getting this error:

Quote:

- 第8行col 1:结束预期

-- line 8 col 1: "End" expected





这是我的代码:

===============





This is my code:
===============

Imports System.IO
Imports System.Net
Imports System.Data
Partial Class SendUsingSMPP
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
Dim WebRequest As Net.WebRequest
Dim WebResonse As Net.WebResponse
Dim Server As String = ""
Dim Port As String = ""
Dim UserName As String = ""
Dim Password As String = ""
Dim type As Integer = 0
Dim Message As String = "Test Message"
Message = HttpUtility.UrlEncode(Message)
If (Message = 2) Or (Message = 6) Then
Message = ConvertToUnicode(Message)
End If
Dim DLR As Integer = 1
Dim Source As String = ""
Dim Destination As String = ""
Dim WebResponseString As String = ""
Dim URL As String = "http://" & Server & ":" & Port &
"/bulksms/bulksms?username=" & UserName & "&password=" & Password & "&type=" &
type & "&dlr=" & DLR & "&destination=" & Destination & "&source=" &Source & "&message=" & Message & ""
WebRequest = Net.HttpWebRequest.Create(URL)
WebRequest.Timeout = 25000
Try
WebResonse = WebRequest.GetResponse
Dim reader As IO.StreamReader = New
IO.StreamReader(WebResonse.GetResponseStream)
WebResponseString = reader.ReadToEnd()
WebResonse.Close()
Response.Write(WebResponseString)
Catch ex As Exception
WebResponseString = "Request Timeout"
Response.Write(WebResponseString)
End Try
End Sub
Public Function ConvertToUnicode(ByVal str As String) As String
Dim ArrayOFBytes() As Byte =
System.Text.Encoding.Unicode.GetBytes(str)
Dim UnicodeString As String = ""
Dim v As Integer
For v = 0 To ArrayOFBytes.Length - 1
If v Mod 2 = 0 Then
Dim t As Integer = ArrayOFBytes(v)
ArrayOFBytes(v) = ArrayOFBytes(v + 1)
ArrayOFBytes(v + 1) = t
End If
Next
For v = 0 To ArrayOFBytes.Length - 1
Dim c As String = Hex$(ArrayOFBytes(v))
If c.Length = 1 Then
c = "0" & c
End If
UnicodeString = UnicodeString & c
Next
Return UnicodeString
End Function
End Class





帮助解决这个问题问题,顺便说一下我不懂vb.net代码。



Help resolving this issue, By the way I do not understand a vb.net code.

推荐答案





帮助解决这个问题问题,顺便说一下我不懂vb.net代码。



Help resolving this issue, By the way I do not understand a vb.net code.


Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load



to


to

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)_
Handles Me.Load



Handles Me.Load是上一行的一部分


Handles Me.Load is part of previous line


这篇关于将VB.NET转换为C#.Net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 04:39