is this ok with arrays

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
rodchar said:
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.
 
sorry bout that, I wasn't thinking.


Cor Ligthert said:
Rodchanr,

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
 

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

Back
Top