Operator Overloading


The syntax for defining an operator for a class is as follows:

  [ <attributes> ] Public [ Overloads ] Shared [ Shadows ] _  [ Widening | Narrowing ]  Operator symbol ( operands ) As type     ... End Operator 

The operator’s symbol can be +, -, *, /, \, ^, &, <<, >>, =, <>, <, >, <=, >=, Mod, Not, And, Or, Xor, Like, IsTrue, IsFalse, or CType.

Some operands come in pairs, and if you define one, you must define the other. The pairs are = and <>, < and >, <= and >=, and IsTrue and IsFalse.

If you define And and IsFalse, Visual Basic uses them to define the AndAlso operator. Similarly, if you define Or and IsTrue, Visual Basic automatically provides the OrElse operator.




Visual Basic 2005 with  .NET 3.0 Programmer's Reference
Visual Basic 2005 with .NET 3.0 Programmer's Reference
ISBN: 470137053
EAN: N/A
Year: 2007
Pages: 417

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net