none
Syntax Imporvement for Vb.Net RRS feed

  • General discussion

  • I have a suggestion for a possible syntax improvement in visual basic.net. It's towards the initialization portion of a one line multiple declaration. For example, a one line multiple declaration currently looks like this:

    'Syntax:
    Dim a, b, c As Integer
    
    'Output:
    'a = 0
    'b = 0
    'c = 0

    However, if I wish to set all the variables to 5 instead of the default 0, I'm force to do this:

    Dim a, b, c As Integer a = 5 b = 5 c = 5

    I propose an initialization of those variables like this:

    'Syntax:
    Dim a, b, c As Integer = 5
    
    'Output:
    'a = 5
    'b = 5
    'c = 5

    This would allow for an easier way to set multiple variables to the same value when they're initially declared. Often times I find myself having to write multiple lines of code to set variables the same value if they differ from the default value. The improvement would lead to shorter and more efficient coding.
    Friday, December 27, 2013 11:27 PM

All replies