Oversættelse fra C# til vb.net
Er der en der kan hjælpe mig med at oversætte følgende C# til vb.net?delegate string DownloadString(string uri);
private void button1_Click(object sender, EventArgs e)
{
// Instantiate delegates with DownloadString's signature:
DownloadString download1 = new WebClient().DownloadString;
DownloadString download2 = new WebClient().DownloadString;
// Start the downloads:
IAsyncResult cookie1 = download1.BeginInvoke("http://www.google.dk", null, null);
IAsyncResult cookie2 = download2.BeginInvoke("http://www.google.com", null, null);
// Perform some random calculation:
double seed = 1.23;
for (int i = 0; i < 1000000; i++) seed = Math.Sqrt(seed + 1000);
// Get the results of the downloads, waiting for completion if necessary.
// Here's where any exceptions will be thrown:
string s1 = download1.EndInvoke(cookie1);
string s2 = download2.EndInvoke(cookie2);
string s3 = s1 == s2 ? "Same" : "Different";
string s4 = "";
}
Jeg har selv oversat det til følgende, men det fejler... (fejlbeskrivelse ses et par linier længere nede)
Delegate Function DownloadString(ByVal uri As String) As String
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' Instantiate delegates with DownloadString's signature:
'Fejler i nedenstående linier, fejl: Overload resolution failed because no accessible "DownloadString" accepts this number of arguments.
Dim download1 As DownloadString = New WebClient().DownloadString
Dim download2 As DownloadString = New WebClient().DownloadString
' Start the downloads:
Dim cookie1 As IAsyncResult = download1.BeginInvoke("http://www.google.dk", Nothing, Nothing)
Dim cookie2 As IAsyncResult = download2.BeginInvoke("http://www.google.com", Nothing, Nothing)
' Perform some random calculation:
Dim seed As Double = 1.23
Dim i As Integer = 0
While i < 1000000
seed = Math.Sqrt(seed + 1000)
System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1)
End While
' Get the results of the downloads, waiting for completion if necessary.
' Here's where any exceptions will be thrown:
Dim s1 As String = download1.EndInvoke(cookie1)
Dim s2 As String = download2.EndInvoke(cookie2)
Dim s3 As String = If(s1 = s2, "Same", "Different")
Dim s4 As String = ""
End Sub