|
-
Jun 21st, 2007, 02:09 PM
#1
Thread Starter
Lively Member
[RESOLVED] [2005] Arrays...
I was wondering if someone could clarify something for me.
When declaring an array is there any difference with these:
Dim sendBytes As [Byte]()
Dim sendBytes() as Byte
What's the [] for in the first example?
Thanks in advance.
-
Jun 21st, 2007, 02:16 PM
#2
My usual boring signature: Nothing
 
-
Jun 21st, 2007, 02:26 PM
#3
Thread Starter
Lively Member
Re: [2005] Arrays...
Blah I hate how there is 10 ways to do the same thing now.... Thanks for the quick response!
-
Jun 21st, 2007, 10:32 PM
#4
Re: [RESOLVED] [2005] Arrays...
When you use square brackets like that you are telling the compiler to NOT treat the word as a language key word. Note that if you don't use the brackets the word Byte will turn blue, indicating that it is a VB.NET key word. Thus you are specifying the VB.NET Byte data type. If you do use the brackets then you are specifying the System.Byte structure as the type, not the inbuilt Byte data type.
Having said that, the inbuilt Byte data type is implemented using the System.Byte type so there really is no difference in the end. There are other situations where the brackets are more menaingful, e.g.
vb.net Code:
Dim start As Date = Date.Today
Dim [end] As Date = start.AddDays(10)
In that case you have to use the square brackets in order to use "end" as an identifier or else it will be interpreted as the "End" key word and produce a syntax error. Note that in that situation the name of the variable is still "end", not "[end]". The brackets are not part of the identifier itself, but just indicate that it is an identifier and not a key word.
-
Jun 22nd, 2007, 09:51 AM
#5
Thread Starter
Lively Member
Re: [RESOLVED] [2005] Arrays...
That was most helpful. Thanks!
-
Jun 22nd, 2007, 10:45 AM
#6
Re: [RESOLVED] [2005] Arrays...
Hunh, I knew about that in SQL, but didn't realize it had made it into VB.
In general, it's a bad idea to use it just because of the potential confusion that can arise. However, if you have to you have to.
My usual boring signature: Nothing
 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|