public int Position
{
get
{
if (Session[\"Position\"] != null)
{
Position = Convert.ToInt32(Session[\"Position\"]);
}
There's nothing particularly string-like about session state items.
Why wouldn't you just follow the KISS principle and do something like
public int Position
{
get { return (int) ( Session["Position"] ?? 5 ) ; }
set { Session["Position"] = value ; }
}
or (depending on your actual requirements/specs:
public int Position
{
get { return Session["Pointer"] as int? ?? position ?? 5 ; }
set { position = value ; }
}
private int? position ; // backing store