Home All Groups Group Topic Archive Search About

is this ok with arrays

Author
27 Jun 2005 3:16 AM
rodchar
hey all,

i have the following dim statement:

        Dim myArray() As Boolean = {enum.value1 = True, enum.value2 = True,
enum.value3 = True, enum.value4 = True, enum.value5 = True}

instead of

dim myArray() as boolean={true,true,true,true,true}

or is there a better way for readability?

thanks,
rodchar

Author
27 Jun 2005 6:56 AM
Cor Ligthert
Rodchanr,

>
>        Dim myArray() As Boolean = {enum.value1 = True, enum.value2 = True,
> enum.value3 = True, enum.value4 = True, enum.value5 = True}
>
> instead of
>
> dim myArray() as boolean={true,true,true,true,true}
>
Did you use Option Strict On.

In my idea are the however not the same and gives the above

false,false,false,false,false.

Therefore what do you want to do and what do you want to express for
readability?

Cor
Author
28 Jun 2005 4:15 AM
rodchar
sorry bout that, I wasn't thinking.


Show quoteHide quote
"Cor Ligthert" wrote:

> Rodchanr,
>
> >
> >        Dim myArray() As Boolean = {enum.value1 = True, enum.value2 = True,
> > enum.value3 = True, enum.value4 = True, enum.value5 = True}
> >
> > instead of
> >
> > dim myArray() as boolean={true,true,true,true,true}
> >
> Did you use Option Strict On.
>
> In my idea are the however not the same and gives the above
>
> false,false,false,false,false.
>
> Therefore what do you want to do and what do you want to express for
> readability?
>
> Cor
>
>
>
Author
27 Jun 2005 8:21 AM
Herfried K. Wagner [MVP]
"rodchar" <rodc***@discussions.microsoft.com> schrieb:
>        Dim myArray() As Boolean = {enum.value1 = True, enum.value2 = True,
> enum.value3 = True, enum.value4 = True, enum.value5 = True}
>
> instead of
>
> dim myArray() as boolean={true,true,true,true,true}
>
> or is there a better way for readability?

Both samples are not semantically equivalent.  The first line will compare
enumeration values with 'True', which doesn't necessarily lead to the value
'True' written to the array.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>