you can do this by writing public static functions. static functions you dont need to instantiate the class. You can call these methods directly using the class.
eg:
using System;
namespace MyNamespace
{
public class GlobalMethods
{
public GlobalMethods()
{
}
public static int Sum (int a, int b)
{
return a + b;
}
}
}
You can invoke the Sum method of the class in your webforms without declaring the instance of the class
private void Button1_Click(object sender, System.EventArgs e)
{
TextBox1.Text = Sum(5, 20).ToString();
}
Regards
Ganesh
|