What is the return type of Session("Something")?

  • Thread starter Thread starter marcwentink
  • Start date Start date
M

marcwentink

This probably is a very noob question
What is the return type of Session("Something")?

I want to change:

If Not Session("Name") Is Nothing Then
LoginId = Session("Name").ToString


to something like

MyObject = Session("Name")
If Not MyObject Is Nothing Then
LoginId = MyObject.ToString
 
Stephany Young schreef:

Works, including the ToString call, which would be a polymorphic call
from a general reference I presume? Or is the Object type really a
Session Object type and not a general root for all Objects in VB, and
not like Object in Java?

Thanks a lot!
 
Every type is derived from type Object.

Object exposes a ToString() method therefore every type exposes a ToString()
method.

You can cast the returned object as type session:

Dim mySession As Session = CType(returnedObject, Session)
 
Stephany Young schreef:
Every type is derived from type Object.

Hey, just to confirm, this is then a .NET property I think, not in VB
but in C# also, all objects are derived from type Object. Is that
correct?

As you might suggest, I am fairly new to .NET.

And thanks again, learned another little piece of .NET today.
 
Back
Top