VB. NET does not fully support the operation method.

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.