quiero hacer esto, pero conseguir este error:¿Utiliza métodos de extensión en .NET 2.0?
Error 1 Cannot define a new extension method because the compiler required type 'System.Runtime.CompilerServices.ExtensionAttribute' cannot be found. Are you missing a reference to System.Core.dll? [snipped some path stuff]
he visto algunas respuestas aquí que dice, usted tiene que definir este atributo a sí mismo.
Cómo lo hago?
EDITAR: Esto es lo que tengo:
[AttributeUsage (AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method)]
public sealed class ExtensionAttribute : Attribute
{
public static int MeasureDisplayStringWidth (this Graphics graphics, string text)
{
}
}
No; necesitas * dos * clases; uno para el atributo; uno para el (los) método (s) de extensión; actualizará. –