asp.net.ph

ContextStaticAttribute Class

System Namespace


Indicates that the value of a static field is unique for a particular context.

ContextStaticAttribute Class Members

Collapse   Constructors

Visibility Constructor Parameters
public ContextStaticAttribute ( )

Remarks

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.

Example

[ 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 );
    }
}
See Also

Attribute   Context Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph