help deciphering getReponseStream Microsoft Sample code snippet

  • Thread starter Thread starter squelly
  • Start date Start date
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
 
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
 
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
 
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.
 
Back
Top