Session Variables & C# Casting

R

Rajesh Abraham

I am new to Asp world and I have a doubt as follows. I
have a class called objTranslator, which I declare and
initiate global.asax as follows.

Session_Start
csTranslator.objTranslator sesObjTranslator= new
objTranslator();
Session["sesTranslator"]=sesObjTranslator;
----------------
Now in WebForm

private csTranslator.objTranslator webTranslator;

In Page Load

if(Session["sesTranslator"]!=null)
webTranslator=(objTranslator)Session["sesTranslator"];

The question is why do I have to explictly cast the
session variable sesTransilator to objTransilator while it
is holding a reference to sesObjTranslator.

So actually what type is the session variable.

In VB.Net one can directly use

webTranslator=Session("sesTranslator")

What is the difference here?

Thanks,

Rajesh Abraham Chacko
 

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

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top