voglio fare questo, ma sempre questo errore:Utilizzo dei metodi di estensione in .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]
Ho visto alcune risposte qui che dice, si deve definire questo attributo da soli.
Come faccio?
EDIT: Questo è quello che ho:
[AttributeUsage (AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method)]
public sealed class ExtensionAttribute : Attribute
{
public static int MeasureDisplayStringWidth (this Graphics graphics, string text)
{
}
}
No; hai bisogno di * due * lezioni; uno per l'attributo; uno per il/i metodo/i di estensione; aggiornerà. –