Session Variables & C# Casting

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rajesh Abraham

    #1

    Session Variables & C# Casting

    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.ob jTranslator sesObjTranslato r= new
    objTranslator() ;
    Session["sesTransla tor"]=sesObjTranslat or;
    ----------------
    Now in WebForm

    private csTranslator.ob jTranslator webTranslator;

    In Page Load

    if(Session["sesTransla tor"]!=null)
    webTranslator=( objTranslator)S ession["sesTransla tor"];

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

    So actually what type is the session variable.

    In VB.Net one can directly use

    webTranslator=S ession("sesTran slator")

    What is the difference here?

    Thanks,

    Rajesh Abraham Chacko

Working...