System Namespace
Indicates that the value of a static field is unique for a particular context.
A static field marked with ContextStaticAttribute is not shared between contexts. If the indicated static field is accessed on a different context, it will contain a different value.
For more information about using attributes, see Extending Metadata Using Attributes.
[ VB ]
Imports System
Class SampleClass
Private a As Integer
Private Shared b As Integer
<ContextStatic ( ) > Private Shared c As Integer
Private d As Integer = 5
Private Shared e As Integer = 6
<ContextStatic ( ) > Private Shared f As Integer = 7
Sub New ( )
a = 1
b = 2
c = 3
End Sub
Sub Method1 ( )
Response.Write ( "{0}", a )
Response.Write ( "{0}", b )
Response.Write ( "{0}", c )
Response.Write ( "{0}", d )
Response.Write ( "{0}", e )
Response.Write ( "{0}", f )
End Sub
End Class
[ C# ]
using System;
class MyClass
{
int a;
static int b;
[ ContextStatic ]
static int c;
int d=5;
static int e=6;
[ ContextStatic ]
static int f=7;
MyClass ( )
{
a = 1;
b = 2;
c = 3;
}
void Method1 ( )
{
Response.Write ( "{0}", a );
Response.Write ( "{0}", b );
Response.Write ( "{0}", c );
Response.Write ( "{0}", d );
Response.Write ( "{0}", e );
Response.Write ( "{0}", f );
}
}
Attribute Context