我正在开发 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;
}
}
我在我的子项目中引用了图书馆项目,我的孩子和图书馆项目位于两个不同的解决方案中。
在儿童应用程序中
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
这是每个项目的入口点。
In this App.xaml.cs
文件我正在创建这个对象Properties and calling setValues method.
我在这里看到的只是静态变量值被覆盖,但方法没有被覆盖。为什么会这样?我在这里做错了什么吗?
我得到 ASDF 并列出 Adam 和 Eve 作为输出
但我需要 ASDF 并列出 Kyla 和 Sophia 作为输出。
如何实现这一目标?
EDIT
我如何使用这些值:
在我的基地:
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
}
}