help deciphering getReponseStream Microsoft Sample code snippet

S

squelly

In the VB.net framework class library document for
HTTPWebresponse.getResponseStream the following code snippet appears:

....
Dim read(256) As [Char]
' Reads 256 characters at a time.
Dim count As Integer = readStream.Read(read, 0, 256)
Console.WriteLine("HTML..." + ControlChars.Lf + ControlChars.Cr)
While count > 0
' Dumps the 256 characters to a string and displays the string to
the console.
Dim str As New [String](read, 0, count)
Console.Write(str)
count = readStream.Read(read, 0, 256)
End While
....

I've never come across the syntax for the declarations of [Char] and
[String], and the sample seems to work with or without the brackets.

Anyone know what the brackets are for?
Thanks,
Squelly
 
J

Joe Feser

Might be old VB code.

[] works like SQL where you can have a reserved word still be used.

i think you can declare a variable named [String] if declared this way.

[] is not needed.

Joe Feser
 
J

Joe Feser

Bad English, sorry I didn't read what I sent

It allows you to use "reserved words" as variables in VB.NET

I am not sure why they have it around the datatype.

[] is not needed.

Joe

Joe Feser said:
Might be old VB code.

[] works like SQL where you can have a reserved word still be used.

i think you can declare a variable named [String] if declared this way.

[] is not needed.

Joe Feser

squelly said:
In the VB.net framework class library document for
HTTPWebresponse.getResponseStream the following code snippet appears:

...
Dim read(256) As [Char]
' Reads 256 characters at a time.
Dim count As Integer = readStream.Read(read, 0, 256)
Console.WriteLine("HTML..." + ControlChars.Lf + ControlChars.Cr)
While count > 0
' Dumps the 256 characters to a string and displays the string to
the console.
Dim str As New [String](read, 0, count)
Console.Write(str)
count = readStream.Read(read, 0, 256)
End While
...

I've never come across the syntax for the declarations of [Char] and
[String], and the sample seems to work with or without the brackets.

Anyone know what the brackets are for?
Thanks,
Squelly
 
S

squelly

Joe Feser said:
Bad English, sorry I didn't read what I sent

It allows you to use "reserved words" as variables in VB.NET

I am not sure why they have it around the datatype.

[] is not needed.

Joe

Thanks for the sanity check. I hunted high and low for a reference
that would explain it, and was coming up empty.
Have a good one.
 

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

Top