Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / March 2008

Tip: Looking for answers? Try searching our database.

string, int and session

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
rodchar - 08 Mar 2008 06:18 GMT
hey all,
can someone please tell me if there's a big difference among the following:
i want to store a string and an int in session.
is it better to store it like:
1. delimited string (i.e. session["test"]="test1" + ";" + 1
2. in an array
3. or 2 separate sessions
how would each one rate?

thanks,
rodchar
sloan - 08 Mar 2008 09:51 GMT
If they are not related, then I would store them in seperate session
variables.

If they're related....lets say you want to store the
EmpID (int) and EmployeeLoginName (string), I would create a mini wrapper
object.

[Serializable]
public class EmployeeLoginInfo
{
   private int _empID = 0;
   private string _employeeLoginName = string.Empty;

   public EmployeeLoginInfo( int empID , string employeeLoginName )
{
_empID = empID;
_employeeLoginName = employeeLoginName;
}

   public int EmpID { { return _empID;}}
   public string EmployeeLoginName { get { return _employeeLoginName;}}
}

and then I would session that mini object.

Delimited String << Heck No
Array << Heck No

That's my vote.

To me, using the mini object means I only have to pay the casting price
once.
And my code make more sense, because I don't have a bunch of disjoint
properties flying all over the place.

You can check this blog entry as well:

http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!151.entry

> hey all,
> can someone please tell me if there's a big difference among the
[quoted text clipped - 8 lines]
> thanks,
> rodchar
Mark Rae [MVP] - 08 Mar 2008 14:33 GMT
> [Serializable]

Not necessary if the class to be stored in Session contains only primitive
datatypes:
http://safari.oreilly.com/0596001177/progcsharp-CHP-21-SECT-6

> Delimited String << Heck No

Agreed.

> Array << Heck No

Probably not, though generics are usually OK to store in Session...

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net

rodchar - 09 Mar 2008 17:54 GMT
should the mini object be nested in a class or would it be better in a
separate file?

> If they are not related, then I would store them in seperate session
> variables.
[quoted text clipped - 47 lines]
> > thanks,
> > rodchar
Mark Rae [MVP] - 09 Mar 2008 18:20 GMT
>> public class EmployeeLoginInfo
>>
>> and then I would session that mini object.
>
> should the mini object be nested in a class

The (mini) object *is* a class...

> or would it be better in a separate file?

Totally irrelevant to the compiler...

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net

rodchar - 18 Mar 2008 23:51 GMT
thanks for the help everyone,
rod.

> hey all,
> can someone please tell me if there's a big difference among the following:
[quoted text clipped - 7 lines]
> thanks,
> rodchar

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.