Link to home
Start Free TrialLog in
Avatar of Abdu_Allah
Abdu_Allah

asked on

How to refence a class's member in a shared(static in C#) function

Hi, To better understand my problem please consider the code below. I want to use the member upoadcount in the shared sub DoSomething(..)
Partial Public Class Main
    Inherits System.Web.UI.Page
    Public uploadcount As Integer = 0
 
 
    <WebMethod()> _
    Public Shared Sub DoSomething(ByVal s As String)
        If HttpContext.Current.Session("View") Is Nothing Then
            HttpContext.Current.Session("View") = 1 ' 1: Details List
 
        End If
 
     End sub
 
End Class

Open in new window

Avatar of kaufmed
kaufmed
Flag of United States of America image

A static member cannot access an instance member without creating an instance of that class. Have you considered making "uploadcount" static?
Avatar of Abdu_Allah
Abdu_Allah

ASKER

I know that and this is why I'm asking this question, I want to know how to do that in the code that I provided.
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial