說明:書寫AbstractDALFactory的ChooseFactory()方法那一行時,如果先寫等號右邊的代碼時,不會出現智能感知,只有先寫等號左邊的代碼,才能出現
{
public static class ClassManager
{
//調用數據訪問層統一數據訪問方式
private static AbstractDALFactory factory = AbstractDALFactory.ChooseFactory();
private static IClassService classService = factory.CreateClass();
/// 通過班級名稱得到班級ID
public static int GetClassIDByClassName(string className)
{
try
{
return Convert.ToInt32(classService.GetClassIDByClassName(className));
}
catch (Exception ex)
{
throw new Exception(ex.ToString());
}
}
}
}