|
-
Aug 7th, 2003, 01:43 PM
#1
Thread Starter
Hyperactive Member
Dim s As [String] = [String].Emtpy
Dim s As [String] = [String].Emtpy
Is that a valid declaration in vb.net?
I see it in some example code in the msdn but I have no clue what the brackets are for. Can anyone enlighten me?
Also when you actually type the the statement, after you type "As [String]", the IDE removes the Brackes, so only way to do add this kind of declaration is to paste the whole thing and then it will stay.. Can anyone clue me in?
-
Aug 7th, 2003, 02:00 PM
#2
Not sure why you would need any brackets..... if it takes them off, then they are not needed.
Dunno why the MSDN shows them.... maybe just so you know it's a string?
-
Aug 7th, 2003, 03:31 PM
#3
it equates to this :
VB Code:
[COLOR=BLUE]Dim[/COLOR] s [COLOR=BLUE]As[/COLOR] [COLOR=BLUE]String[/COLOR] = [COLOR=BLUE]String[/COLOR].Empty
the [ ] get removed automatically if you type it with them in
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Aug 7th, 2003, 03:34 PM
#4
Originally posted by dynamic_sysop
the [ ] get removed automatically if you type it with them in
He wanted to know why the MSDN showed code like that with the brackets, he already posted that VB automaticly takes them off....
-
Aug 7th, 2003, 04:13 PM
#5
yeah i overlooked that small detail lol
anyway , the [ ] are only there as you said , to show it's a string.
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Aug 7th, 2003, 04:43 PM
#6
Thread Starter
Hyperactive Member
Hmm, I don't think it's just to "express" that it's a string because there are certain areas in the code where they have it.. As I said, you can actually paste the whole thing and it will work and the IDE will retain the brackets and it will act as a string. I'm thinking that this might have been something from beta or a earlier version of .Net that actually used the brackets.. see for yourself.. paste this into your browser and look at the code..
ms-help://MS.VSCC.2003/MS.MSDNQTR.2003APR.1033/cpguide/html/cpconnon-blockingserversocketexample.htm
Interesting...
-
Aug 7th, 2003, 06:40 PM
#7
i couldnt find that link to open it , should it have a http:// bit on it somewhere?
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Aug 7th, 2003, 06:42 PM
#8
Originally posted by dynamic_sysop
i couldnt find that link to open it , should it have a http:// bit on it somewhere?
No, it's a stupid propriatary MS crap for IE.... ugh I hate how they make up there own web ****...
-
Aug 7th, 2003, 08:18 PM
#9
Thread Starter
Hyperactive Member
Link Here
sorry, the first link was a local MSDN link.. works if you have 2003 msdn installed and IE on your machine
-
Aug 8th, 2003, 10:29 AM
#10
The brackets are used when a word can have two meanings in the current namespace. For instance if you want to use a shared method of the Enum class you'd have to use [Enum] or else it will think you are trying to declare an Enum. So either the example just used it to show it is using a member of the String class or something about the namespace made it be used.
VB Code:
<Flags()> _
Enum QueryTypes
[Select] = 1
Insert = 2
Update = 4
Delete = 8
End Enum
Dim x As QueryTypes = [Enum].Parse(GetType(QueryTypes), "Insert")
MsgBox(x.ToString)
-
Aug 8th, 2003, 11:04 AM
#11
Thread Starter
Hyperactive Member
Thank you Edneeis, that clears things up
-
Aug 9th, 2003, 09:53 AM
#12
Addicted Member
Originally posted by Edneeis
The brackets are used when a word can have two meanings in the current namespace. For instance if you want to use a shared method of the Enum class you'd have to use [Enum] or else it will think you are trying to declare an Enum. So either the example just used it to show it is using a member of the String class or something about the namespace made it be used.
VB Code:
<Flags()> _
Enum QueryTypes
[Select] = 1
Insert = 2
Update = 4
Delete = 8
End Enum
Dim x As QueryTypes = [Enum].Parse(GetType(QueryTypes), "Insert")
MsgBox(x.ToString)
Sweet! Just like in SQL. That's good to know. Thanks Edneeis!
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
|