A simple example:
Dim pt As New Point (0, 0)
Pt + = New Size (10, 10)
C. Cannot be compiled in VB. NET. The error is
Operator '+' is not defined for types 'System. Drawing. point' and 'System. Drawing. size '.
In fact, let's take a look at the Point's il Code. There is an additional overload.
. Method public hidebysig specialname static
Valuetype System. Drawing. Point op_Addition (valuetype System. Drawing. Point pt,
Valuetype System. Drawing. Size sz) ASME managed
{
// Code size 36 (0x24)
. Maxstack 8
IL_0000: ldarga. s pt
IL_0002: call instance int32 System. Drawing. Point: get_X ()
IL_0007: ldarga. s sz
IL_0009: call instance int32 System. Drawing. Size: get_Width ()
IL_000e: add
IL_000f: ldarga. s pt
IL_0011: call instance int32 System. Drawing. Point: get_Y ()
IL_0016: ldarga. s sz
IL_0018: call instance int32 System. Drawing. Size: get_Height ()
IL_001d: add
IL_001e: newobj instance void System. Drawing. Point:. ctor (int32,
Int32)
IL_0023: ret
} // End of method Point: op_Addition
Instead, you have to change it to Dim pt As New Point (0, 0)
Pt = Point. op_Addition (pt, New Size (10, 10 ))
Check that the latest issue of msdn mag mentioned this problem. The reason is very simple. vb.net compiler does not support Operator Overloading in 100%.
Address: http://www.msdn.microsoft.com/msdnmag/issues/04/12/AdvancedBasics/default.aspx