IDE Warning

B

Brian

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(".",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."

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

Kerry Moorman

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).Concat.

Kerry Moorman
 
P

Phill W.

Brian said:
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".Concat( "a", "b", "c" )
"abc"

? "bob".Concat( "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".Split( "e"c )
(something like)
"fr"
"d"

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

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

HTH,
Phill W.
 

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