Tags: boeing, documents, instance, instead, member, net, qualify, reference, settings, sharp, showpmacfg, static, studioprojects, type, visual, vuepmacfg, watts

instance reference; qualify it with a type name instead

On .Net » .Net C# (C sharp)

5,431 words with 2 Comments; publish: Mon, 31 Dec 2007 12:01:00 GMT; (10062.50, « »)

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)

}

All Comments

Leave a comment...

  • 2 Comments
    • 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" <andrew.c.watts.net-csharp.todaysummary.com.boeing.com> wrote in message

      news:035601c34a36$19315a20$a101280a.net-csharp.todaysummary.com.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)

      > }

      #1; Mon, 31 Dec 2007 12:02:00 GMT
    • 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" <andrew.c.watts.net-csharp.todaysummary.com.boeing.com>

      !Sender: "andrew" <andrew.c.watts.net-csharp.todaysummary.com.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: <035601c34a36$19315a20$a101280a.net-csharp.todaysummary.com.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)

      !}

      !

      !

      #2; Mon, 31 Dec 2007 12:03:00 GMT