tags:

views:

106

answers:

3

I'm converting some C# code into VB.Net and was stuck on second half of this line:

HttpWorkerRequest workerRequest = (HttpWorkerRequest)provider.GetService(typeof(Http WorkerRequest));

What would this code be in VB.NET?

I have the easy part:

Dim workerRequest As HttpWorkerRequest =

+1  A: 

I think something like this:

Dim workerRequest As HttpWorkerRequest = CType(provider.GetService(GetType(HttpWorkerRequest)), HttpWorkerRequest)
Fredrik Mörk
Unfortunately that doesn't work, the error is where I got stuck:GetType(Http WorkerRequest))
Josh
There was an extra space that had been sneaking in there; fixed it.
Fredrik Mörk
+1  A: 

Hi there.

Try

Dim workerRequest As HttpWorkerRequest = DirectCast(provider.GetService(GetType(HttpWorkerRequest), HttpWorkerRequest)

Cheers. Jas.

Jason Evans
You where missing a close parenthesis:Dim workerRequest As HttpWorkerRequest = DirectCast(provider.GetService(GetType(HttpWorkerRequest)), HttpWorkerRequest)
Josh
Cheers for that, totally missed it :)
Jason Evans
+1  A: 

The other code on here is right so i wont repeat, but you may find this very useful:

http://www.developerfusion.com/tools/convert/csharp-to-vb/

NickAtuShip
+1. Awesome link!
David Stratton
Although I'm providing a complete line, the site gives the followign error when I try the code:Statement fragment: please enter a complete statement.
Josh
Hmmm - ive never had that - try pasting in the entire method?
NickAtuShip