By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,671 Members | 1,355 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,671 IT Pros & Developers. It's quick & easy.

instance reference; qualify it with a type name instead

P: n/a
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)
}

Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"andrew" <an************@boeing.com> wrote in message
news:03****************************@phx.gbl...
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)
}

Nov 13 '05 #2

P: n/a
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" <an************@boeing.com>
!Sender: "andrew" <an************@boeing.com>
!Subject: instance reference; qualify it with a type name instead
!Date: Mon, 14 Jul 2003 11:31:10 -0700
!Lines: 31
!Message-ID: <03****************************@phx.gbl>
!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)
!}
!
!

Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.