instance reference; qualify it with a type name instead

A

andrew

C:\Documents and Settings\watts\My Documents\Visual Studio
Projects\boeing\showPMACfg\vuePMAcfg\vuePMAcfg.cs(88):
Static member 'vuePMAcfg.pmaDataHash.pmaDataHash1' cannot
be accessed with an instance reference; qualify it with a
type name instead

OK I have this class And the hash and the function shows
up in type ahead. I tried declaring it and later accessing
it like this:

private vuePMAcfg.pmaDataHash pmaDataObj;
....
pmaDataShareArray.Add(pmaDataObj.pmaDataHash1);

But I get the error above ... if I try
private vuePMAcfg.pmaDataHash pmaDataObj = new
vuePMAcfg.pmaDataHash(); ... I get the same error.

What does the error mean and how do I get to the items &
function ??? Thanks

public class pmaDataHash
{
public pmaDataHash()
{
}
public static Hashtable pmaDataHash1 = new
Hashtable();
public string GetFolderBylevel(string filePath,int level)
}
 
I

Ignacio Machin

Hi andrew,

The static methods/properties or variables need to be qualified with the
class name:

pmaDataShareArray.Add(pmaDataObj.pmaDataHash1) needs to be written like:
pmaDataShareArray.Add( pmaDataHash.pmaDataHash1);

See that the pmaDataHash1 belong to the class as a whole, ont to a
particular instance, therefore all the instances(objects of type
pmaDataHash) will share the same pmaDataHash1.

What is what you are trying to do anyway?

Hope this help,
 
Y

Yan-Hong Huang[MSFT]

Hello Andrew,

The error message already showed where the problem is.

In the code, the pmaDataHash1 is a static member of pmaDataHash class, it
must be refer to by pmaDataHash's static function and it must be associated
with this type, not an instance of this type.

In your code listed out, I can not find the place you refer to pmaDataHash1
data member, but from the error message, you maybe associate it with an
instance.

Hope this helps.

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! ¨C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
!Content-Class: urn:content-classes:message
!From: "andrew" <[email protected]>
!Sender: "andrew" <[email protected]>
!Subject: instance reference; qualify it with a type name instead
!Date: Mon, 14 Jul 2003 11:31:10 -0700
!Lines: 31
!Message-ID: <[email protected]>
!MIME-Version: 1.0
!Content-Type: text/plain;
! charset="iso-8859-1"
!Content-Transfer-Encoding: 7bit
!X-Newsreader: Microsoft CDO for Windows 2000
!X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
!Thread-Index: AcNKNhkxgy1v8BoBTHKuIYtvBPL1jg==
!Newsgroups: microsoft.public.dotnet.languages.csharp
!Path: cpmsftngxa06.phx.gbl
!Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:168993
!NNTP-Posting-Host: TK2MSFTNGXA09 10.40.1.161
!X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
!
!C:\Documents and Settings\watts\My Documents\Visual Studio
!Projects\boeing\showPMACfg\vuePMAcfg\vuePMAcfg.cs(88):
!Static member 'vuePMAcfg.pmaDataHash.pmaDataHash1' cannot
!be accessed with an instance reference; qualify it with a
!type name instead
!
!OK I have this class And the hash and the function shows
!up in type ahead. I tried declaring it and later accessing
!it like this:
!
!private vuePMAcfg.pmaDataHash pmaDataObj;
!...
!pmaDataShareArray.Add(pmaDataObj.pmaDataHash1);
!
!But I get the error above ... if I try
!private vuePMAcfg.pmaDataHash pmaDataObj = new
!vuePMAcfg.pmaDataHash(); ... I get the same error.
!
!What does the error mean and how do I get to the items &
!function ??? Thanks
!
!public class pmaDataHash
!{
! public pmaDataHash()
! {
! }
! public static Hashtable pmaDataHash1 = new
!Hashtable();
!public string GetFolderBylevel(string filePath,int level)
!}
!
!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top