출처2 : https://stackoverflow.com/questions/1522605/using-extension-methods-in-net-2-0
public static void DoubleBuffered(this Control control, bool enable)
{
var doubleBufferPropertyInfo = control.GetType().GetProperty("DoubleBuffered", BindingFlags.Instance | BindingFlags.NonPublic);
doubleBufferPropertyInfo.SetValue(control, enable, null);
}
this.DoubleBuffered(true);
.net 3.5 보다 낮은 버전일 때는 아래와 같은 구문을 프로젝트에 한 번만 작성해 주면된다.
// you need this once (only), and it must be in this namespace
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class
| AttributeTargets.Method)]
public sealed class ExtensionAttribute : Attribute { }
}