Re: 2 dimension arrays
- From: "Hans Kesting" <news.2.hansdk@xxxxxxxxxxxxxxx>
- Date: Tue, 30 Aug 2005 14:28:28 +0200
Andrew wrote:
> Thanks for your reply.
> How do I declare an array as a session variable ?
> I tried:
>
> int [] marked = new int [50];
> Session["marked[0] "] = 2;
>
> I got a syntax error.
>
untested code:
--------------
string[,] marked = (string[,])Session["marked"];
if (marked == null)
{
// nothing yet in session, so create it
marked = new string[50][2];
Session["marked"] = marked;
}
// use it
marked[12, 1] = "test";
-------------
Note: as you have a *reference* to this array, there is really only one array
so a change to 'marked' will "also update" the array "stored in the Session"
(to phrase it loosely). No need to "put the changed array back in the Session".
Hans Kesting
> "Hans Kesting" wrote:
>
>> Andrew wrote:
>>> Hi,
>>>
>>> I have an array of 50 rows and 2 columns that I want to make
>>> available to a user. As he goes thru the system, he will be updating
>>> and editing the array. This is unique to each user in the session.
>>>
>>> eg. public string[,] marked = new String[50][2].
>>>
>>> How do you suggest I do it ? Do I declare it as global variable, or
>>> is it possible to put it as a session variable?
>>>
>>> TIA. Cheers.
>>> Andrew.
>>
>> You will *need* to put in in Session: a "global variable" (static
>> member of some class) is the same for *all* users of your site (the
>> single webapp serves multiple users).
>> If you want to retain user-specific data in server-memory, you have
>> to
>> user Session. (other options: client side using ViewState or hidden
>> inputs
>> or in a database under a user-specific key)
>>
>>
>> Hans Kesting
.
- Follow-Ups:
- Re: 2 dimension arrays
- From: Andrew
- Re: 2 dimension arrays
- References:
- 2 dimension arrays
- From: Andrew
- Re: 2 dimension arrays
- From: Hans Kesting
- Re: 2 dimension arrays
- From: Andrew
- 2 dimension arrays
- Prev by Date: Re: ASPX now with methods and classes
- Next by Date: Connection leak in PhotoManager ?
- Previous by thread: Re: 2 dimension arrays
- Next by thread: Re: 2 dimension arrays
- Index(es):
Relevant Pages
|