Wanted: Help translating C# to VB.NET

  • Thread starter Thread starter Siegfried Heintze
  • Start date Start date
S

Siegfried Heintze

Would someone kindly translate this from C# to VB.NET for me? Thanks.
Siegfried

HttpApplication app=(HttpApplication)sender;
if(app.Request.IsAuthenticated && app.User.Identity is FormsIdentity){
FormsIdentity identity = (FormsIdentity) app.User.Identity;
 
This should be close:

Dim app As HttpApplication
Dim identity As FormsIdentity
app = CType(sender, HttpApplication)
If (app.Request.IsAuthenticated) And (app.User.Identity Is FormsIdentity)
Then
identity = CType(app.User.Identity, FormsIdentity)
End If
 
* "Russell Jones said:
This should be close:

Dim app As HttpApplication
Dim identity As FormsIdentity
app = CType(sender, HttpApplication)
If (app.Request.IsAuthenticated) And (app.User.Identity Is FormsIdentity)
Then
identity = CType(app.User.Identity, FormsIdentity)
End If

I prefer 'DirectCast' in this situation.
 
* "Siegfried Heintze said:
Would someone kindly translate this from C# to VB.NET for me? Thanks.

HttpApplication app=(HttpApplication)sender;
if(app.Request.IsAuthenticated && app.User.Identity is FormsIdentity){
FormsIdentity identity = (FormsIdentity) app.User.Identity;

C# -> VB.NET Converters:

<URL:http://www.aspalliance.com/aldotnet/examples/translate.aspx>
<URL:http://www.kamalpatel.net/ConvertCSharp2VB.aspx>
<URL:http://csharpconverter.claritycon.com/>
<URL:http://www.ragingsmurf.com/vbcsharpconverter.aspx>
<URL:http://www.gotdotnet.com/Community/...mpleGuid=c622348b-18a9-47d6-8687-979975d5957d>

<URL:http://www.remotesoft.com/>
-> "Octopus"
 
This is picky, but it won't run without the "TypeOf":

Dim app As HttpApplication
Dim identity As FormsIdentity
app = CType(sender, HttpApplication)
If (app.Request.IsAuthenticated) And (TypeOf app.User.Identity Is
FormsIdentity)
Then
identity = CType(app.User.Identity, FormsIdentity)
End If
 
Back
Top