VB 10 thoughts (part 5)

 

  1. a NameOf operator
    you could use this similar to TypeOf, but to get the name of a class or a method or property etc.

    NameOf could be used :
    - without any operand to return the name of the current method/property, e.g NameOf()
    - using an object reference ot get a typename, e.g NameOf(Me) gives the name of the current class
    - get the name of the current class in a Shared method by using the Class keyword, NameOf(Class)
    - get the name of a method as a string, NameOf(Foo.Bar) returns “Bar”. Although this last case doesn’t seem important, it does allow for compiler verification

       
         Public Property Text As String
              Get
                  …
              End Get
             Set(ByVal value as String)
                 OnPropertyCahnged(NameOf())
             End Set
         
          End Property

  2. Shared Class’es
    Although a Module is basically a Shared Class, I would like to be able to use Shared Class instead and in particular would like to be able to stop the implied importing of the Module namespace that currently occurs.

  3. Extension methods in classes
    This would be handy to provide methods that are Shared in nature, while allowing for member evaluation. For example, let’s say you have a Class Foo and it has a Count property.  If you were to write obj.FooProperty.Count you could get a null reference exception if obj.FooProperty is Nothing. If however Count was an extension method, you could decide to return -1 if FooProperty was Nothing.


  4. Properties as Extension members
    I saw this posted by a fellow MVP the other day, and think it would be a nice addition. Just as you can have extension methods, have extension properties.
This entry was posted in 491, 5162, 5726. Bookmark the permalink.

2 Responses to VB 10 thoughts (part 5)

  1. I don’t know Bill, but reading through your list, sounds like half the things you want you can already get with C#, perhaps you should switch. ;)xx`

  2. Bill says:

    Hi David,

    Actually so far only about 5 of the items are in C# already, so that’s less than a quarter *so far*. But if the list was for C# I’d have to add a whole lot more such as support for Optional parameters, late binding and dynamic support, true interface mapping, declarative event handling, integrated XML, date literals, to name just a few.

    ;)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>