Home  |  Index  |  Dotnet4all Snippets  |  Submit resources
About  |  Mail us  
Dotnet4all Logo

  non-shared member of a class (Tuesday, December 21, 2004)




Found the following interesting discussion in the Newsgroups:

non-shared member of a class
by:Mike Johnson

I got the error below, can someone provide the answer in code to the problem
listed below. Thanks.

You have tried to reference a non-shared member of a class from within a
shared method or shared method initialize. The following code provides an
example of such a situation:

Class Sample
Public x as Integer 'An instance member
Public Shared Sub Bar()
x = 10 'Produces the error
End Sub
End ClassThe shared method does not actually operate on any one instance of
the class. Instead, each instance has its own copy of x, which causes the
error.

To correct this error

a.. Provide an explicit instance of the class whose member you wish to
reference. In the example above, provide an explicit instance of the class
containing the copy of x which you wish to set equal to 10.
I can't use shared to fix the problem so please explain in code how to do
the above. Thanks


 Reply:
by:Anonymous

 It's kind of funny, when you think about it.

You started your post with the ruse that this was an error you encountered while writing code. You then posted a question verbatim out of a text book.

What's worse, the question has already been answered in your own post. Simply follow the instructions under the line "To correct this error".








1 Comments:

Anonymous Anonymous said...

Well actually it's a bit obvious that he doesn't know the code to do it. Thats what he is asking for twat

11:19 PM  

Post a Comment

 
Previous Posts
    - Visual Studio Hangs when New Project invoked
    - Expandable Menus
    - Having problems using the GetProcesses from a remo...
    - CheckedListBox
    - Datagrid delete problem
    - Distributed application programming
    - content files
    - A little overwhelmed with the number of options......
    - VB.Net Windows App Data Grid
    - Avoid IE control resizing ?

Archives
    - 10/03/2004 - 10/10/2004
    - 10/10/2004 - 10/17/2004
    - 10/17/2004 - 10/24/2004
    - 10/24/2004 - 10/31/2004
    - 10/31/2004 - 11/07/2004
    - 11/21/2004 - 11/28/2004
    - 11/28/2004 - 12/05/2004
    - 12/05/2004 - 12/12/2004
    - 12/12/2004 - 12/19/2004
    - 12/19/2004 - 12/26/2004
    - 12/26/2004 - 01/02/2005
    - 01/23/2005 - 01/30/2005
    - 01/01/2006 - 01/08/2006
    - 09/24/2006 - 10/01/2006

Disclaimer & Terms of Use  | DotNet4All.Com concept & © 2004 - 2007 by  Zelders²  - Holland