This C# code to VB

G

G Dean Blake

I have this code snippet in C# that I have to convert to VB

object o = null;
if (mode == PageTrackingMode.ByApplication) {
o = Page.Application[HitsKey];
}
else if (mode == PageTrackingMode.BySession) {
o = Page.Session[HitsKey];
}

In most of the C# code I see that is referring to Session and Application
variables I see that quotes are used i.e. Page.Session["HitsKey"] which
would translate to Page.Session("HitsKey") in VB. But the code above is
using the brackets without the quotes. What does that mean and how would
that translate to VB?
Thanks,
G
 
M

Mike Newton

G said:
I have this code snippet in C# that I have to convert to VB

object o = null;
if (mode == PageTrackingMode.ByApplication) {
o = Page.Application[HitsKey];
}
else if (mode == PageTrackingMode.BySession) {
o = Page.Session[HitsKey];
}

In most of the C# code I see that is referring to Session and Application
variables I see that quotes are used i.e. Page.Session["HitsKey"] which
would translate to Page.Session("HitsKey") in VB. But the code above is
using the brackets without the quotes. What does that mean and how would
that translate to VB?
Thanks,
G

HitsKey is probably a string variable or constant. Given that it's C#,
it's probably a class variable or a parameter.

The VB would look like this (pardon if the caps go crazy):

Dim o As System.Object = Nothing
If mode = PageTrackingMode.ByApplication Then
o = Page.Application(HitsKey)
Else
If mode = PageTrackingMode.BySession Then
o = Page.Session(HitsKey)
End If
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top