Simple question 'the correct way!'

danfloun

Member
Joined
Apr 5, 2010
Messages
23
Programming Experience
Beginner
HI,

If I do either method it works, so is either okay to use?
I would normally use the latter myself!

VB.NET:
Dim i as integer = 0
Dim url as uri = urlList(i + 1)

VB.NET:
Dim i as integer = 0
Dim url as uri = urlList((i) + 1)

Cheers
Danny
 
While both ways will work I don't see any reason for the extra parenthesis. Do you normally write 2 + 2 or (2) + 2?
 
The whole point of parentheses is to group things together. What's the point of grouping one thing? Why do this:
VB.NET:
Dim url as uri = urlList((i) + 1)
if you wouldn't do this:
VB.NET:
Dim url as uri = (urlList((i) + (1)))
The extra parentheses don't hurt the execution of the code but they don't add anything, plus I think they make the code harder to read, so they are actually bad.
 
The extra parentheses don't hurt the execution of the code but they don't add anything, plus I think they make the code harder to read, so they are actually bad.

I agree. This is an important point. Make your code only as complex as it needs to be.
 
Back
Top