Compiler Error CS1113
Extension methods 'name' defined on value type 'name' cannot be used to create delegates.
Extension methods that are defined for class types can be used to create delegates. Extension methods that are defined for value types cannot.
Associate the extension method with a class type.
Make the method a regular method on the struct.
The following example generates CS1113:
// cs1113.cs
using System;
public static class Extensions
{
public static S ExtMethod(this S s)
{
return s;
}
}
public struct S
{
}
public class Test
{
static int Main()
{
Func<S> f = new S().ExtMethod; // CS1113
return 1;
}
}
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
.NET feedback
.NET is an open source project. Select a link to provide feedback: