Convert C# codes to VB.NET


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Convert C# codes to VB.NET

  1. #1
    Steve Guest

    Convert C# codes to VB.NET


    Dear All,
    Try to understand the following C# codes. Can someone help me convert the
    following codes to VB.NET? What is the meaning of += in C#?

    public void InstantiateIn(Control container)
    }
    LiteralControl l = new LiteralControl();
    l.DataBinding += new EventHandler(this.OnDataBinding);
    container.Controls.Add(l);
    }

    Public void OnDataBinding(object sender, EventArgs e)
    {
    ......
    }

    Thanks,
    Steve

  2. #2
    David A. Rothgery Guest

    Re: Convert C# codes to VB.NET

    Steve <vb.@127.0.0.1> wrote:
    >
    > Dear All,
    > Try to understand the following C# codes. Can someone help me convert the
    > following codes to VB.NET? What is the meaning of += in C#?


    x += y is equivalent to x = x + y in C# or VB.NET.

    However, C# supports operator overloading (letting you redefine the
    meaning of +, for example, for a class), and sometimes language
    designers get clever and use operator overloading for something that's
    not especially intuitive. See C++ stream operations for the cannonical
    example (they work by overloading the bit shifting operators).

    > public void InstantiateIn(Control container)
    > }
    > LiteralControl l = new LiteralControl();
    > l.DataBinding += new EventHandler(this.OnDataBinding);


    The VB.NET equivalent of this line is

    AddHandler l.DataBinding, Addressof(this.OnDataBinding)

    > container.Controls.Add(l);
    > }
    >
    > Public void OnDataBinding(object sender, EventArgs e)
    > {
    > .....
    > }
    >
    > Thanks,
    > Steve
    >


    --
    Dave Rothgery
    Picking nits since 1976
    drothgery@alum.wpi.edu
    http://drothgery.editthispage.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center