What is the difference between Session["uname"]=TextBox1.Text and
Session.Add("uname",TextBox1.Text)?

 Posted by Ddd on 3/7/2011 | Category: ASP.NET Interview questions | Views: 5073 | Points: 40
Answer:

Session["uname"]=TextBox1.Text and Session.Add("uname",TextBox1.Text) are both
used to assign data from the TextBox1 to a key known as "uname". Both commands will create a row in the Session Object.

Difference:

Session["uname"]=TextBox1.Text ; It uses an indexer to assign the data. The indexer refers to the particular row of the session object. The key "uname" is
used to identify the row.
Assigning data using an indexer is faster and more efficient than assigning the data
using the method--Session.Add("uname",TextBox1.Text)


| Alert Moderator 

Comments or Responses

Login to post response