Hi,
You can use the concept of Singleton pattern.
Refer the link
http://msdn.microsoft.com/en-us/library/ff650316.aspx[
^] for implementing singleton pattern.
You can also make your class static and then when you call member of that class first time the object of that class will be created and the same object will be used through out the project.
Example with Static class.
public static class A
{
public static int RunMyMethod()
{
}
}
public class YourPageClass
{
int result = A.RunMyMethod();
}
But my suggestion is to use Singleton pattern to create single instance of the class.
Example of Singleton pattern from MSDN.
public class Singleton
{
private static Singleton instance;
private Singleton() {}
public static Singleton Instance
{
get
{
if (instance == null)
{
instance = new Singleton();
}
return instance;
}
}
}
By using this calass you will make sure only one instance of the class will be crated and used through out the project.