473,395 Members | 1,468 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Static variables in ASP .NET/VB .NET

RB
Hi clever people :-)

I've noticed a lot of people stating not to use static variables with
ASP.NET, and, as I understand it, the reason is because the variable is
shared across user sessions - which is Very Bad (tm) for reasons I
understand!

However, does this rule apply only to global static variables, or does
it apply to procedure-level static variables.

e.g. If I have a class:
==================================================
Public Class MyPretendClass
Inherits System.Web.UI.Page
ReadOnly Property SomeProperty() As Integer
Get
Static i As Integer = -1
If i = -1 Then
i = Integer.Parse(Request.Params("MyQueryStringArgumen t"))
End If
Return t
End Get
End Property

' REST OF CLASS, INCLUDING USE OF SomeProperty PROPERTY
End Class
==================================================

and I output SomeProperty to an asp:Label how will it work if I have 2
users (Alice and Bob), where Alice requests the page with a query string
value of 1, and Bob then accesses the page with a value of 2.

Obviously Alice will have 1 in the label, but what value will Bob have?

Many thanks,

RB.
Oct 31 '07 #1
16 8583
Your initial statement is false. There is nothing wrong with static
variables if they fill the task at hand, be they "global" or at a procedure
level.

"RB" <ow************@mailinator.comwrote in message
news:2O*********************@eclipse.net.uk...
Hi clever people :-)

I've noticed a lot of people stating not to use static variables with
ASP.NET, and, as I understand it, the reason is because the variable is
shared across user sessions - which is Very Bad (tm) for reasons I
understand!

However, does this rule apply only to global static variables, or does it
apply to procedure-level static variables.

e.g. If I have a class:
==================================================
Public Class MyPretendClass
Inherits System.Web.UI.Page
ReadOnly Property SomeProperty() As Integer
Get
Static i As Integer = -1
If i = -1 Then
i = Integer.Parse(Request.Params("MyQueryStringArgumen t"))
End If
Return t
End Get
End Property

' REST OF CLASS, INCLUDING USE OF SomeProperty PROPERTY
End Class
==================================================

and I output SomeProperty to an asp:Label how will it work if I have 2
users (Alice and Bob), where Alice requests the page with a query string
value of 1, and Bob then accesses the page with a value of 2.

Obviously Alice will have 1 in the label, but what value will Bob have?

Many thanks,

RB.

Oct 31 '07 #2
RB
Fair point - I retract my original statement, but leave the rest of the
question open ;-)

Cheers,

RB.

Aidy wrote:
Your initial statement is false. There is nothing wrong with static
variables if they fill the task at hand, be they "global" or at a procedure
level.

"RB" <ow************@mailinator.comwrote in message
news:2O*********************@eclipse.net.uk...
>Hi clever people :-)

I've noticed a lot of people stating not to use static variables with
ASP.NET, and, as I understand it, the reason is because the variable is
shared across user sessions - which is Very Bad (tm) for reasons I
understand!

However, does this rule apply only to global static variables, or does it
apply to procedure-level static variables.

e.g. If I have a class:
================================================= =
Public Class MyPretendClass
Inherits System.Web.UI.Page
ReadOnly Property SomeProperty() As Integer
Get
Static i As Integer = -1
If i = -1 Then
i = Integer.Parse(Request.Params("MyQueryStringArgumen t"))
End If
Return t
End Get
End Property

' REST OF CLASS, INCLUDING USE OF SomeProperty PROPERTY
End Class
================================================= =

and I output SomeProperty to an asp:Label how will it work if I have 2
users (Alice and Bob), where Alice requests the page with a query string
value of 1, and Bob then accesses the page with a value of 2.

Obviously Alice will have 1 in the label, but what value will Bob have?

Many thanks,

RB.

Oct 31 '07 #3
Can't you just test to get the answer? Or can you not be bothered doing
your own homework despite it only involving typing in one function and
pressing F5? Bob will also have 1 (assuming he viewed the site in a
reasonable enough time after Alice, of course)

"RB" <ow************@mailinator.comwrote in message
news:hJ*********************@eclipse.net.uk...
Fair point - I retract my original statement, but leave the rest of the
question open ;-)

Cheers,

RB.

Aidy wrote:
>Your initial statement is false. There is nothing wrong with static
variables if they fill the task at hand, be they "global" or at a
procedure level.

"RB" <ow************@mailinator.comwrote in message
news:2O*********************@eclipse.net.uk...
>>Hi clever people :-)

I've noticed a lot of people stating not to use static variables with
ASP.NET, and, as I understand it, the reason is because the variable is
shared across user sessions - which is Very Bad (tm) for reasons I
understand!

However, does this rule apply only to global static variables, or does
it apply to procedure-level static variables.

e.g. If I have a class:
================================================ ==
Public Class MyPretendClass
Inherits System.Web.UI.Page
ReadOnly Property SomeProperty() As Integer
Get
Static i As Integer = -1
If i = -1 Then
i = Integer.Parse(Request.Params("MyQueryStringArgumen t"))
End If
Return t
End Get
End Property

' REST OF CLASS, INCLUDING USE OF SomeProperty PROPERTY
End Class
================================================ ==

and I output SomeProperty to an asp:Label how will it work if I have 2
users (Alice and Bob), where Alice requests the page with a query string
value of 1, and Bob then accesses the page with a value of 2.

Obviously Alice will have 1 in the label, but what value will Bob have?

Many thanks,

RB.
Oct 31 '07 #4
this search will yield a wealth of information:

http://www.google.com/search?source=...cation+asp.net

"RB" <ow************@mailinator.comwrote in message
news:2O*********************@eclipse.net.uk...
Hi clever people :-)

I've noticed a lot of people stating not to use static variables with
ASP.NET, and, as I understand it, the reason is because the variable is
shared across user sessions - which is Very Bad (tm) for reasons I
understand!

However, does this rule apply only to global static variables, or does it
apply to procedure-level static variables.

e.g. If I have a class:
==================================================
Public Class MyPretendClass
Inherits System.Web.UI.Page
ReadOnly Property SomeProperty() As Integer
Get
Static i As Integer = -1
If i = -1 Then
i = Integer.Parse(Request.Params("MyQueryStringArgumen t"))
End If
Return t
End Get
End Property

' REST OF CLASS, INCLUDING USE OF SomeProperty PROPERTY
End Class
==================================================

and I output SomeProperty to an asp:Label how will it work if I have 2
users (Alice and Bob), where Alice requests the page with a query string
value of 1, and Bob then accesses the page with a value of 2.

Obviously Alice will have 1 in the label, but what value will Bob have?

Many thanks,

RB.

Oct 31 '07 #5
statics are statics, shared for all threads in the appdomain. public and
private only controls scope (access).
-- bruce (sqlwork.com)

RB wrote:
Hi clever people :-)

I've noticed a lot of people stating not to use static variables with
ASP.NET, and, as I understand it, the reason is because the variable is
shared across user sessions - which is Very Bad (tm) for reasons I
understand!

However, does this rule apply only to global static variables, or does
it apply to procedure-level static variables.

e.g. If I have a class:
==================================================
Public Class MyPretendClass
Inherits System.Web.UI.Page
ReadOnly Property SomeProperty() As Integer
Get
Static i As Integer = -1
If i = -1 Then
i = Integer.Parse(Request.Params("MyQueryStringArgumen t"))
End If
Return t
End Get
End Property

' REST OF CLASS, INCLUDING USE OF SomeProperty PROPERTY
End Class
==================================================

and I output SomeProperty to an asp:Label how will it work if I have 2
users (Alice and Bob), where Alice requests the page with a query string
value of 1, and Bob then accesses the page with a value of 2.

Obviously Alice will have 1 in the label, but what value will Bob have?

Many thanks,

RB.
Oct 31 '07 #6
RB
I actually have done a test (that's where the code comes from), and I
get the value 2 for "Bob" (where Alice and Bob are 2 seperate instances
of IE).

I posted because this wasn't the behaviour I was exactly expecting, and
I wanted to know what behaviour other people were expecting. and you
suggest that I was right not to expect this behaviour.

Therefore, does anyone know why Bob get's a different value from Alice?

Actually, thinking about it, it would have to work this way, otherwise
every post-back to the server would get the same value - even if the
query string changed - I think I'll check that behaviour next.

Cheers,

RB

Aidy wrote:
Can't you just test to get the answer? Or can you not be bothered doing
your own homework despite it only involving typing in one function and
pressing F5? Bob will also have 1 (assuming he viewed the site in a
reasonable enough time after Alice, of course)

"RB" <ow************@mailinator.comwrote in message
news:hJ*********************@eclipse.net.uk...
>Fair point - I retract my original statement, but leave the rest of the
question open ;-)

Cheers,

RB.

Aidy wrote:
>>Your initial statement is false. There is nothing wrong with static
variables if they fill the task at hand, be they "global" or at a
procedure level.

"RB" <ow************@mailinator.comwrote in message
news:2O*********************@eclipse.net.uk...
Hi clever people :-)

I've noticed a lot of people stating not to use static variables with
ASP.NET, and, as I understand it, the reason is because the variable is
shared across user sessions - which is Very Bad (tm) for reasons I
understand!

However, does this rule apply only to global static variables, or does
it apply to procedure-level static variables.

e.g. If I have a class:
=============================================== ===
Public Class MyPretendClass
Inherits System.Web.UI.Page
ReadOnly Property SomeProperty() As Integer
Get
Static i As Integer = -1
If i = -1 Then
i = Integer.Parse(Request.Params("MyQueryStringArgumen t"))
End If
Return t
End Get
End Property

' REST OF CLASS, INCLUDING USE OF SomeProperty PROPERTY
End Class
=============================================== ===

and I output SomeProperty to an asp:Label how will it work if I have 2
users (Alice and Bob), where Alice requests the page with a query string
value of 1, and Bob then accesses the page with a value of 2.

Obviously Alice will have 1 in the label, but what value will Bob have?

Many thanks,

RB.
Oct 31 '07 #7
RB
I tested that behaviour with a HyperLink that incremented the query
string parameter each time, and that worked (i.e. it incremented it).

Private ReadOnly Property SomeProperty()
Get
Static i As Integer = -1
If i = -1 Then
i = Integer.Parse(Request.Params("MyQueryStringArgumen t"))
End If
Return i
End Get
End Property
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
lblTest.Text = SomeProperty
HyperLink1.NavigateUrl =
"http://localhost/StaticTest/WebForm1.aspx?MyQueryStringArgument=" &
(SomeProperty + 1)
End Sub

Therefore, I'm assuming that procedure-level static variables persist
ONLY for the lifetime of the page (or any object I suppose) they belong
to. If someone could confirm that, I'd really appreciate it :-)

Cheers,

RB.
RB wrote:
I actually have done a test (that's where the code comes from), and I
get the value 2 for "Bob" (where Alice and Bob are 2 seperate instances
of IE).

I posted because this wasn't the behaviour I was exactly expecting, and
I wanted to know what behaviour other people were expecting. and you
suggest that I was right not to expect this behaviour.

Therefore, does anyone know why Bob get's a different value from Alice?

Actually, thinking about it, it would have to work this way, otherwise
every post-back to the server would get the same value - even if the
query string changed - I think I'll check that behaviour next.

Cheers,

RB

Aidy wrote:
>Can't you just test to get the answer? Or can you not be bothered
doing your own homework despite it only involving typing in one
function and pressing F5? Bob will also have 1 (assuming he viewed
the site in a reasonable enough time after Alice, of course)

"RB" <ow************@mailinator.comwrote in message
news:hJ*********************@eclipse.net.uk...
>>Fair point - I retract my original statement, but leave the rest of
the question open ;-)

Cheers,

RB.

Aidy wrote:
Your initial statement is false. There is nothing wrong with static
variables if they fill the task at hand, be they "global" or at a
procedure level.

"RB" <ow************@mailinator.comwrote in message
news:2O*********************@eclipse.net.uk.. .
Hi clever people :-)
>
I've noticed a lot of people stating not to use static variables
with ASP.NET, and, as I understand it, the reason is because the
variable is shared across user sessions - which is Very Bad (tm)
for reasons I understand!
>
However, does this rule apply only to global static variables, or
does it apply to procedure-level static variables.
>
e.g. If I have a class:
============================================== ====
Public Class MyPretendClass
Inherits System.Web.UI.Page
ReadOnly Property SomeProperty() As Integer
Get
Static i As Integer = -1
If i = -1 Then
i = Integer.Parse(Request.Params("MyQueryStringArgumen t"))
End If
Return t
End Get
End Property
>
' REST OF CLASS, INCLUDING USE OF SomeProperty PROPERTY
End Class
============================================== ====
>
and I output SomeProperty to an asp:Label how will it work if I
have 2 users (Alice and Bob), where Alice requests the page with a
query string value of 1, and Bob then accesses the page with a
value of 2.
>
Obviously Alice will have 1 in the label, but what value will Bob
have?
>
Many thanks,
>
RB.
>
Oct 31 '07 #8
RB
That's what I thought as well - but doing testing suggests that
procedure-level statics work differently, and exist only for the
lifetime of the page.

Ah - is that the thing then. Is it the case that if I had 2
near-simultaneous web-page requests, then the static property value
*would* be shared?

bruce barker wrote:
statics are statics, shared for all threads in the appdomain. public and
private only controls scope (access).
-- bruce (sqlwork.com)

RB wrote:
>Hi clever people :-)

I've noticed a lot of people stating not to use static variables with
ASP.NET, and, as I understand it, the reason is because the variable
is shared across user sessions - which is Very Bad (tm) for reasons I
understand!

However, does this rule apply only to global static variables, or does
it apply to procedure-level static variables.

e.g. If I have a class:
================================================= =
Public Class MyPretendClass
Inherits System.Web.UI.Page
ReadOnly Property SomeProperty() As Integer
Get
Static i As Integer = -1
If i = -1 Then
i = Integer.Parse(Request.Params("MyQueryStringArgumen t"))
End If
Return t
End Get
End Property

' REST OF CLASS, INCLUDING USE OF SomeProperty PROPERTY
End Class
================================================= =

and I output SomeProperty to an asp:Label how will it work if I have 2
users (Alice and Bob), where Alice requests the page with a query
string value of 1, and Bob then accesses the page with a value of 2.

Obviously Alice will have 1 in the label, but what value will Bob have?

Many thanks,

RB.
Oct 31 '07 #9
RB
AHHH - I think i know what's going on - I'm being a thicky (naturally!)

Every user has their own instantiation of the page object in question,
so the procedure level static variables *are* individual to each user,
as the procedure they are in is not shared.

Therefore, it is safe to use this technique (of caching things in a
static variable) as different users will not be able to share values.

If the above is not correct, please let me know!!

Cheers,

RB.

RB wrote:
That's what I thought as well - but doing testing suggests that
procedure-level statics work differently, and exist only for the
lifetime of the page.

Ah - is that the thing then. Is it the case that if I had 2
near-simultaneous web-page requests, then the static property value
*would* be shared?

bruce barker wrote:
>statics are statics, shared for all threads in the appdomain. public
and private only controls scope (access).
-- bruce (sqlwork.com)

RB wrote:
>>Hi clever people :-)

I've noticed a lot of people stating not to use static variables with
ASP.NET, and, as I understand it, the reason is because the variable
is shared across user sessions - which is Very Bad (tm) for reasons I
understand!

However, does this rule apply only to global static variables, or
does it apply to procedure-level static variables.

e.g. If I have a class:
================================================ ==
Public Class MyPretendClass
Inherits System.Web.UI.Page
ReadOnly Property SomeProperty() As Integer
Get
Static i As Integer = -1
If i = -1 Then
i = Integer.Parse(Request.Params("MyQueryStringArgumen t"))
End If
Return t
End Get
End Property

' REST OF CLASS, INCLUDING USE OF SomeProperty PROPERTY
End Class
================================================ ==

and I output SomeProperty to an asp:Label how will it work if I have
2 users (Alice and Bob), where Alice requests the page with a query
string value of 1, and Bob then accesses the page with a value of 2.

Obviously Alice will have 1 in the label, but what value will Bob have?

Many thanks,

RB.
Oct 31 '07 #10
Perhaps, but I fail to see what advantage this could possibly give you.
Understanding that the Page class disintegrates --*Poof* and is completely
gone when it has finished and the page is sent out to the requesting browser.
Static -- within the context you are using it (in private transient scope)
accomplishes "nada".
-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com

"RB" wrote:
AHHH - I think i know what's going on - I'm being a thicky (naturally!)

Every user has their own instantiation of the page object in question,
so the procedure level static variables *are* individual to each user,
as the procedure they are in is not shared.

Therefore, it is safe to use this technique (of caching things in a
static variable) as different users will not be able to share values.

If the above is not correct, please let me know!!

Cheers,

RB.

RB wrote:
That's what I thought as well - but doing testing suggests that
procedure-level statics work differently, and exist only for the
lifetime of the page.

Ah - is that the thing then. Is it the case that if I had 2
near-simultaneous web-page requests, then the static property value
*would* be shared?

bruce barker wrote:
statics are statics, shared for all threads in the appdomain. public
and private only controls scope (access).
-- bruce (sqlwork.com)

RB wrote:
Hi clever people :-)

I've noticed a lot of people stating not to use static variables with
ASP.NET, and, as I understand it, the reason is because the variable
is shared across user sessions - which is Very Bad (tm) for reasons I
understand!

However, does this rule apply only to global static variables, or
does it apply to procedure-level static variables.

e.g. If I have a class:
================================================= =
Public Class MyPretendClass
Inherits System.Web.UI.Page
ReadOnly Property SomeProperty() As Integer
Get
Static i As Integer = -1
If i = -1 Then
i = Integer.Parse(Request.Params("MyQueryStringArgumen t"))
End If
Return t
End Get
End Property

' REST OF CLASS, INCLUDING USE OF SomeProperty PROPERTY
End Class
================================================= =

and I output SomeProperty to an asp:Label how will it work if I have
2 users (Alice and Bob), where Alice requests the page with a query
string value of 1, and Bob then accesses the page with a value of 2.

Obviously Alice will have 1 in the label, but what value will Bob have?

Many thanks,

RB.
Oct 31 '07 #11
RB
Hi Peter,

The advantage is that it's an easy way of caching objects for the
duration of the page - think of it loosely like the singleton pattern.

I could do the same thing with private variables within the class of
course - I just think the static approach looks neater!

I was just a little concerned that it would not work the way I thought
it would - hence my posting...

Cheers,

RB.

Peter Bromberg [C# MVP] wrote:
Perhaps, but I fail to see what advantage this could possibly give you.
Understanding that the Page class disintegrates --*Poof* and is completely
gone when it has finished and the page is sent out to the requesting browser.
Static -- within the context you are using it (in private transient scope)
accomplishes "nada".
-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com

"RB" wrote:
>AHHH - I think i know what's going on - I'm being a thicky (naturally!)

Every user has their own instantiation of the page object in question,
so the procedure level static variables *are* individual to each user,
as the procedure they are in is not shared.

Therefore, it is safe to use this technique (of caching things in a
static variable) as different users will not be able to share values.

If the above is not correct, please let me know!!

Cheers,

RB.

RB wrote:
>>That's what I thought as well - but doing testing suggests that
procedure-level statics work differently, and exist only for the
lifetime of the page.

Ah - is that the thing then. Is it the case that if I had 2
near-simultaneous web-page requests, then the static property value
*would* be shared?

bruce barker wrote:
statics are statics, shared for all threads in the appdomain. public
and private only controls scope (access).
-- bruce (sqlwork.com)

RB wrote:
Hi clever people :-)
>
I've noticed a lot of people stating not to use static variables with
ASP.NET, and, as I understand it, the reason is because the variable
is shared across user sessions - which is Very Bad (tm) for reasons I
understand!
>
However, does this rule apply only to global static variables, or
does it apply to procedure-level static variables.
>
e.g. If I have a class:
============================================== ====
Public Class MyPretendClass
Inherits System.Web.UI.Page
ReadOnly Property SomeProperty() As Integer
Get
Static i As Integer = -1
If i = -1 Then
i = Integer.Parse(Request.Params("MyQueryStringArgumen t"))
End If
Return t
End Get
End Property
>
' REST OF CLASS, INCLUDING USE OF SomeProperty PROPERTY
End Class
============================================== ====
>
and I output SomeProperty to an asp:Label how will it work if I have
2 users (Alice and Bob), where Alice requests the page with a query
string value of 1, and Bob then accesses the page with a value of 2.
>
Obviously Alice will have 1 in the label, but what value will Bob have?
>
Many thanks,
>
RB.
Nov 1 '07 #12
"RB" <ow************@mailinator.comwrote in message
news:0K******************************@eclipse.net. uk...
The advantage is that it's an easy way of caching objects for the duration
of the page - think of it loosely like the singleton pattern.
I guess it depends on your definition of the word 'advantage' - in this
case, there's no advantage (IMO) at all, since you get no additional benefit
or functionality...
I could do the same thing with private variables within the class of
course
Indeed, which (I believe) was Peter's point...
I just think the static approach looks neater!
Well obviously that's a personal preference, and nothing wrong with that...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Nov 1 '07 #13
>I just think the static approach looks neater!
>>
Well obviously that's a personal preference, and nothing wrong with
that...
In addition to "looking neater", the use of the static keyworkd makes the
var only accecible from the proc in which it's declared.

In the same way as private fields are better(safer due to being inaccessible
outside the scope of their use) compared to public fields, I would say that
proc static vars are better again, if you can get away with using them as
they prevent misuse from outside the proc.

--
Rory
Nov 1 '07 #14
"Rory Becker" <Ro********@newsgroup.nospamwrote in message
news:b0**************************@msnews.microsoft .com...
>>I just think the static approach looks neater!
Well obviously that's a personal preference, and nothing wrong with
that...

In addition to "looking neater", the use of the static keyworkd makes the
var only accecible from the proc in which it's declared.
In C# (unlike C++), static variables can't be declared inside methods (which
I assume is what you mean by 'proc')...

E.g. this compiles:

public partial class MyClass: System.Web.UI.Page
{
static string MyString = String.Empty;

protected void Page_Load(object sender, EventArgs e)
{

}
}

but this doesn't:

public partial class MyClass: System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
static string MyString = String.Empty;
}
}
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Nov 1 '07 #15
In C# (unlike C++), static variables can't be declared inside methods

Fair enough but the ubject of this post details that the OP was using VB.net
which does allow such.

VB used Static as a keyword for this since a long way before VB.Net which
is probably wht Shared is used to mean Static in the other sense.

--
Rory
Nov 1 '07 #16
"Rory Becker" <Ro********@newsgroup.nospamwrote in message
news:b0**************************@msnews.microsoft .com...
>In C# (unlike C++), static variables can't be declared inside methods

Fair enough but the subject of this post details that the OP was using
VB.net which does allow such.

VB used Static as a keyword for this since a long way before VB.Net which
is probably why Shared is used to mean Static in the other sense.
Apologies - you're quite correct. According to MSDN:

[Static] Specifies that one or more declared local variables are to remain
in existence and retain their latest values after termination of the
procedure in which they are declared.

Remarks
Normally, a local variable in a procedure ceases to exist as soon as the
procedure terminates. A static variable remains in existence and retains its
most recent value. The next time your code calls the procedure, the variable
is not reinitialized, and it still holds the latest value you assigned to
it. A static variable continues to exist for the lifetime of the class or
module in which it is defined.

Rules
Declaration Context. You can use Static only on local variables. This means
the declaration context for a Static variable must be a procedure or a block
within a procedure, and it cannot be a source file, namespace, class,
structure, or module.

You cannot use Static inside a structure procedure.

Combined Modifiers. You cannot specify Static together with ReadOnly,
Shadows, or Shared in the same declaration.

Behavior
The behavior of any local variable depends on whether it is declared in a
Shared procedure. If the procedure is Shared, all its local variables are
automatically shared, including the Static variables. There is only one copy
of such a variable for the entire application. You call a Shared procedure
using the class name, not a variable pointing to an instance of the class.

If the procedure is not Shared, its local variables are instance variables,
including the Static variables. There is an independent copy of each
variable in each instance of the class. You call a nonshared procedure using
a variable pointing to a specific instance of the class. Any variable in
that instance is independent of a variable with the same name in another
instance. Therefore, they can hold different values.
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Nov 1 '07 #17

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: James | last post by:
Hello Java NG, I not sure if this is the right NG for this type of question but if not please let me know which is, TIA Any way first off let me say I'm a student and this WAS last weeks lab,...
2
by: katekukku | last post by:
HI, Could anyone please tell me what are static variables and what exactly are there features. I am a little bit confused. Thank You
9
by: Bryan Parkoff | last post by:
I have noticed that C programmers put static keyword beside global variable and global functions in C source codes. I believe that it is not necessary and it is not the practice in C++. Static...
4
by: Dave | last post by:
I used the following class and .aspx code below to understand how static works on variables and methods taken from...
8
by: Simone Chiaretta | last post by:
I've a very strange behaveour related to a website we built: from times to times, something should happen on the server, and all static variables inside the web application, both defined inside aspx...
28
by: Dennis | last post by:
I have a function which is called from a loop many times. In that function, I use three variables as counters and for other purposes. I can either use DIM for declaring the variables or Static. ...
5
by: Jesper Schmidt | last post by:
When does CLR performs initialization of static variables in a class library? (1) when the class library is loaded (2) when a static variable is first referenced (3) when... It seems that...
9
by: CDMAPoster | last post by:
About a year ago there was a thread about the use of global variables in A97: http://groups.google.com/group/comp.databases.ms-access/browse_frm/thread/fedc837a5aeb6157 Best Practices by Kang...
55
by: Zytan | last post by:
I see that static is more restricted in C# than in C++. It appears usable only on classes and methods, and data members, but cannot be created within a method itself. Surely this is possible in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.