【发布时间】:2014-03-30 09:46:14
【问题描述】:
我正在开发 Windows 8 Phone 应用程序,我这里有两件事,一个是图书馆项目,另一个是普通应用程序,让我先解释一下我的代码:
在图书馆项目中
class A
{
public static string empName ="ABC";
public static int empID = 123;
public virtual List<string> ListOfEmployees()
{
List<string> empList = new List<string>
empList.Add("Adam");
empList.Add("Eve");
return empList;
}
}
我在我的子项目中引用了库项目,我的孩子和库项目在 2 个不同的解决方案中。
在子应用程序中
class Properties : A
{
public void setValues(){
empName ="ASDF"
ListOfEmployees();
}
public override List<string> ListOfEmployees()
{
List<string> empList = new List<string>
empList.Add("Kyla");
empList.Add("Sophia");
return empList;
}
}
现在在每个子应用程序中,我们 App.xaml.cs 这是每个项目的入口点。
在这个App.xaml.cs 文件中,我正在创建这个Properties and calling setValues method. 的对象
我在这里看到的只是静态变量值被覆盖,但方法没有被覆盖。为什么会这样?我在这里做错了吗?
我得到了 ASDF 并列出了 Adam 和 Eve 作为输出
但我需要 ASDF 并列出 Kyla 和 Sophia 作为输出。
如何做到这一点?
编辑
我如何使用这些值:
在我的基地:
class XYZ : A
{
// now i can get empName as weel as the ListOfEmployees()
string employeeName = null;
public void bind()
{
employeeName = empName ;
ListOfEmployees(); // here is the bug where i always get Adam and Eve and not the Kyla and sophia
}
}
【问题讨论】:
标签: c# wpf windows-phone-8 windows-phone class-library