Below is an example of using "static class" in C#:
Ref.: http://msdn.microsoft.com/en-us/library/79b3xss3(VS.80).aspx
Main class()
{
...
public static class UtilFunc
{
private static string g_strLogFileURL = "test";
public static void SetLogDir(string strURL)
{
if (strURL != "") g_strLogFileURL = strURL;
}
public static string LogToFile()
{
return g_strLogFileURL;
}
}
...
}
Other Class()
{
....
// static class can't be instantiated, simply use its APIs as below
MessageBox.Show(UtilFunc.LogToFile());
....
}
Thursday, March 25, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment