CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Threaded View

  1. #1
    Join Date
    May 2006
    Posts
    306

    Extension Methods & Pointers

    Okay, so I'm having this problem.

    I defined this animation function (similar to jQuery if you have heard of it) for controls. Notice: I condensed the code into one box, the two methods are in two different classes.

    Code:
    private unsafe void FormMain_Click(object sender, EventArgs e)
    {
        this.Animate(&Width, this.Width + 50);
    }
    
    public static Control(this Control C, int* Property, int Value, float Time)
    {
        // Calculate Steps
        &Property += 50;
    }
    Now, the way I have it set up is that you can pass a property by reference, so that the function can edit it directly, instead of use a copy, right?

    It keeps giving me an error in the FormMain_Click:

    "Cannot take the address of the given expression."

    Please help. Also, if I was to get this working correctly, I don't know how to get the interval set correctly. It has to do with dividing the Time by the property and the value passed, but I don't know the algorithm.
    Last edited by code?; August 15th, 2009 at 04:02 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured