IDE Warning

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Brian

    IDE Warning

    Hi,
    No matter how i do this, I get the same warning. I don't understand the
    warning....
    Dim FILETYPE as string() = {"tree;.tree;*. tree"}

    for x as integer = 0 to ubound(FILETYPE )
    Orginal line---------------------------------------
    FILETYPE(0) = Lcase(FILETYPE( 0).Concat(".", FILETYPE(0)))
    --------------------------------------------------

    new try...---------------------------------------
    dim strx as string = FILETYPE(0)
    strx = Lcase(FILETYPE( 0).Concat(".",F ILETYPE(0)))

    the warning message i am getting is "Access of shared member, constant
    member, enum member or nested type through an instance qualifying expression
    will not be evaluated."

    Can anyone explain this to me to help me understand it?
    Brian


  • =?Utf-8?B?S2VycnkgTW9vcm1hbg==?=

    #2
    RE: IDE Warning

    Brian,

    Concat is a shared method of the String class and should be accessed through
    the class, not an instance of the class.

    You should be using String.Concat instead of FILETYPE(0).Con cat.

    Kerry Moorman


    "Brian" wrote:
    Hi,
    No matter how i do this, I get the same warning. I don't understand the
    warning....
    Dim FILETYPE as string() = {"tree;.tree;*. tree"}
    >
    for x as integer = 0 to ubound(FILETYPE )
    Orginal line---------------------------------------
    FILETYPE(0) = Lcase(FILETYPE( 0).Concat(".", FILETYPE(0)))
    --------------------------------------------------
    >
    new try...---------------------------------------
    dim strx as string = FILETYPE(0)
    strx = Lcase(FILETYPE( 0).Concat(".",F ILETYPE(0)))
    >
    the warning message i am getting is "Access of shared member, constant
    member, enum member or nested type through an instance qualifying expression
    will not be evaluated."
    >
    Can anyone explain this to me to help me understand it?
    Brian
    >
    >
    >

    Comment

    • Phill W.

      #3
      Re: IDE Warning

      Brian wrote:
      No matter how i do this, I get the same warning. I don't understand the
      warning....
      FILETYPE(0) = Lcase(FILETYPE( 0).Concat(".", FILETYPE(0)))
      the warning message i am getting is "Access of shared member, constant
      member, enum member or nested type through an instance qualifying expression
      will not be evaluated."
      The Concat() method takes the string values that you /give/ it and bolts
      them all together; it doesn't care which String /object/ you call the
      method on (well, it obviously does because it's griping, but the
      /result/ would be the same):

      ? "fred".Conc at( "a", "b", "c" )
      "abc"

      ? "bob".Conca t( "a", "b", "c" )
      "abc"

      Different "starting" strings; same result.

      To get around the confusion that the above might cause, the compiler is
      now (VB'2005+) being /stricter/ in how you are allowed to call this (and
      similar) methods. You have to use ...

      String.Concat( ... )

      .... instead. This is because Concat (and Join, and others) are Shared
      methods on the String class, and you invoke them using the Class name,
      not via an instance of that class.

      Contrast this with the Split() method (an Instance method). This takes
      the value of the String object on which you /call/ it and hacks /that/
      up into an array of Strings so that ...

      ? "fred".Spli t( "e"c )
      (something like)
      "fr"
      "d"

      .... gives you a different answer from ...

      ? "bob".Split ( "e"c )
      (something like)
      "bob"

      HTH,
      Phill W.

      Comment

      Working...