locked
Can I implement a custom operator for the Integer type? RRS feed

  • Question

  • User-403353736 posted

    I have been developing in VB.net for a cople of years now. I really miss the increment and decrement operators for integers that I grew attached to while using Java and C#. I have seen posts explaining how to implement a custom operator for a class that I have written, but I have not seen any examples of how to do it for a basic type like Integer. Is it possible? If so, what would I need to do?

    Every time I talk about missing the ++/-- operators the first thing I hear is "well all you have to do is i += 1". This obvisouly works and has gotten me this far, but sometimes I would like to do things with pairs of objects in the same statement such as:

    For i as Integer = 0 to args.Count - 1

        cmdSQL.Parameters.Add(New SqlParameter(Ctype(args(i), String), args(i + 1)))

        i += 2

    Next

    I know I would only save one line of code with the increment operator, but it would look cleaner to me Cool Thanks for any help.

     

    Wednesday, September 30, 2009 12:46 PM

Answers