Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 2005 > Pro Visual Basic 2005
Pro Visual Basic 2005 For advanced Visual Basic coders working in version 2005. Beginning-level questions will be redirected to other forums, including Beginning VB 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro Visual Basic 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old October 31st, 2006, 06:29 PM
Friend of Wrox
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default What’s the implication of putting a type in []?

Found the following at: http://msdn.microsoft.com/library/de...erfactory.asp:

You can generate a new handler instance for ea. HTTP request by creating a class
that implements the IHttpHandlerFactory interface. In the fol. example, a
HttpHandler factory is used to create different handlers for an HTTP GET request and
an HTTP POST request. One of the handlers is an instance of a synchronous handler;
the other handler is an instance an asynchronous handler.
Imports System
Imports System.Web

Namespace Handlers
  Class HandlerFactory
    Implements IHttpHandlerFactory

    Public Function GetHandler(ByVal context    As HttpContext, _
                               ByVal reqType    As String, _
                               ByVal url        As [String], _
                               ByVal pathXlated As [String] _
                               ) As IHttpHandler _
                                    Implements IHttpHandlerFactory.GetHandler

        Dim handlerToReturn As IhttpHandler

        With context.Request.RequestType
            If "get" = .ToLower() Then
                handlerToReturn = New SynchHandler()
                If "post" = .ToLower() Then
                    handlerToReturn = New AsynchHandler()
                    handlerToReturn = Nothing
                End If
            End If
        End With

        Return handlerToReturn

    End Function
    Public Sub ReleaseHandler(ByVal handler As IhttpHandler _
                             ) Implements IHttpHandlerFactory.ReleaseHandler

    End Sub
    Public ReadOnly Property IsReusable() As Boolean
            ' To enable pooling, return True here.
            ' This keeps the handler in memory.
            Return False
        End Get
    End Property

  End Class
End Namespace
Register your custom HttpHandler factory by creating an entry in Web.config as follows:
      <add verb="GET,POST" path="*.MyFactory" type="Handlers.HandlerFactory, Handlers" />
What is the meaning of the “[String]” in the declaration of Public Function GetHandler()?
Old November 6th, 2006, 01:12 PM
SQLScott's Avatar
Wrox Author
Join Date: Dec 2004
Posts: 338
Thanks: 0
Thanked 2 Times in 2 Posts

I think it doesn't mean anything. I asked around to make sure and all the feedback I got was that:

ByVal url AS String

Is the same as:

ByVal url As [String]

If anyone knows otherwise, i'd like to know.

Scott Klein
Author - Professional SQL Server 2005 XML
Old November 6th, 2006, 05:53 PM
Friend of Wrox
Join Date: May 2006
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts

Square brackets are used to enable using reserved words or keywords as identifiers, which I suppose could somehow be useful.
I don't see how you could do that with String as in the example you posted. I looked at the link you supplied, and can't see any reason that would be needed there or why they used the brackets..

As an example of how they would be used (in the case where it was found to be of use): you would use square brackets to define a class that has a keyword for a name. Here, Alias is a vb keyword:

Public Class [Alias]
    Public Name As String
End Class
Then, wherever you use the class as a paramter, you use the square brackets as well to indicate you mean the class rather than the keyword:
Private Sub TestMe(ByVal s As [Alias])
End Sub
Again - I see no use in the example from MS. But I could be missing something.

Woody Z http://www.learntoprogramnow.com
Old November 15th, 2006, 03:05 PM
Friend of Wrox
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts

I created a test app with this feature, built it, and then subjected it to ILDASM. I had two opposite declarations
    Public Sub S1(strVar1 As String, strVar2 As [String]) . . .
    Public Sub S2(strVar3 As [String], strVar4 As String) . . .
    All for strings were handled in the representation in ILDASM exactly the same. The only difference was the number used to sequentialize them (I'm not referring to my sequentialization, but the compiler's).

Apparently this does nothing whatsoever, period.

Thanks for the input on it though.
Old November 15th, 2006, 03:36 PM
Friend of Wrox
Join Date: May 2006
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts

quote:Originally posted by BrianWren
Apparently this does nothing whatsoever, period.
I am glad you checked that. It is what I would have expected but haven't checked myself.

I can't see any way the actual purpose of square brackets (aliasing a keyword or reserved word) could be used on a type (such as String).

Woody Z http://www.learntoprogramnow.com

Similar Threads
Thread Thread Starter Forum Replies Last Post
What’s the .NET Way to test if Folder Exists? BrianWren Pro Visual Basic 2005 3 March 14th, 2007 08:35 AM
What’s the .NET Way to test if Folder Exists? BrianWren Visual Basic 2005 Basics 3 January 12th, 2007 07:32 PM
What’s the .NET Way to test if Folder Exists? BrianWren VB.NET 0 November 30th, 2006 02:46 PM
What’s the implication of putting a type in []? BrianWren Pro VB.NET 2002/2003 0 October 31st, 2006 06:32 PM
putting it another way MetsFan BOOK: Professional Crystal Reports for VS.NET 1 June 4th, 2004 12:12 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.