Inline Delegate (C#)
In This Article
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
- This refactoring is the opposite of Name Anonymous Method (C#).
#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;
};
}
}