views:

23

answers:

2

I want to add a new method in Windows.Forms.Form class..

Please help how to do this if anyone knows..

+1  A: 

You can't modify the .NET Framework. You can extend it. When you add a new form in Visual Studio, you will be creating a class that derives from System.Windows.Forms.Form. In that class, you can add all the methods you like.

Also, ASP.NET is used to create web-based applications, not Windows Forms applications. The two have almost nothing to do with each other.

John Saunders
A: 

In .NET 3.5 you can create extension methods to the Form class like so:

 public static class MyExtensions
    {
        public static string Foo( this Form form, string param1 )
        {
            return param1;
        }
    }

Then later you can call (somewhere in the code for the Form of course):

var foo = this.Foo("bar");
Thomas