Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3606744
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:17:17+00:00 2026-05-18T21:17:17+00:00

I am using session objects in C# ASP.net. I like to know whether I

  • 0

I am using session objects in C# ASP.net.

I like to know whether I can declare and use an array of such objects.

For example assume there is a session object “User”, then I say:

User[,] u_sers_ = User[3,4].GetCurrentUser;

What I am trying to do is declare an array of session objects, is this possible?

If it is not possible, how do I declare an array of object “members”?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T21:17:17+00:00Added an answer on May 18, 2026 at 9:17 pm

    Nothing in your code above involves any Session object. You may have some terminology confusion, here:

    The object named Session is a member variable of the Page instance object, among others. It is there as a convenience to refer to the session object for the current user session. You do not do anything to create an ‘array’ of these objects – there is only one per-user-session currently active, and each Page and other similar object can only deal with the current one.

    You put objects in the Session dictionary to use them. Again; this is a single object, automatically created and scoped per-session for you. You do not create it. But you do create individual objects to insert into the Session object, and it stores them for you, keeping track of which Session collection is attached to which session.

    You could certainly put an array of something in the Session dictionary, but I don’t think that’s really what you are looking for here.


    Edit Session usage:

    In one page, you can add things to your Session object:

    UserObject user = new UserObject(Request);
    Session["user"] = user;
    int[] integerValues = {1, 4, 6, 7, 44, 334, 3984};
    Session["integers"] = integerValues;
    object otherStuff = new object();
    Session["other"] = otherStuff;
    

    Then you can refer to those object by their name, after testing to make sure they really do exist and casting them properly. You always must test that the object exists, because the Session could expire at any time.

    UserObject user = Session["user"] as UserObject;
    if(user!=null)
        ...do stuff here...
    int[] integerValues = Session["integers"] as int[];
    if(integerValues!=null)
        ...do stuff here...
    etc...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.