string, int and session

R

rodchar

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
 
S

sloan

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
 
R

rodchar

should the mini object be nested in a class or would it be better in a
separate file?

sloan said:
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


rodchar said:
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
 

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

Top