Connecting Tech Pros Worldwide Forums | Help | Site Map

is this ok with arrays

rodchar
Guest
 
Posts: n/a
#1: Nov 21 '05
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

Cor Ligthert
Guest
 
Posts: n/a
#2: Nov 21 '05

re: is this ok with arrays


Rodchanr,
[color=blue]
>
> 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}
>[/color]
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


Herfried K. Wagner [MVP]
Guest
 
Posts: n/a
#3: Nov 21 '05

re: is this ok with arrays


"rodchar" <rodchar@discussions.microsoft.com> schrieb:[color=blue]
> 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?[/color]

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/>

rodchar
Guest
 
Posts: n/a
#4: Nov 21 '05

re: is this ok with arrays


sorry bout that, I wasn't thinking.


"Cor Ligthert" wrote:
[color=blue]
> Rodchanr,
>[color=green]
> >
> > 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}
> >[/color]
> 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
>
>
>[/color]
Closed Thread


Similar Visual Basic .NET bytes