The requested page is not available for the requested platform. You are viewing the content for Default platform.

Inline Delegate (C#)

Inlines the delegate, creating an anonymous method. If there are no other references to the delegate method, it is removed.

Availability

Available from the context menu or via shortcuts:

  • when the edit cursor, or caret is on a delegate method.

Notes

Example

public class TestClass 
{
    private int Add(int x, int y) 
    {
        return x + y;
    }
    private void TestMethod() 
    {
        Func<int, int, int> adder1 = Add;
    }
}

Result:

public class TestClass 
{
    private void TestMethod() 
    {
        Func<int, int, int> adder1 = delegate(int x, int y) 
        {
            return x + y;
        };
    }
}

Screenshot

rsInlineDelegate