我在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;
}
}
我在子项目中引用的库项目,我的孩子和库项目有两种不同的解决方案。
在其中是每个项目的入口点每个孩子申请我们App.xaml.cs
儿童应用
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
文件我创造的这个Properties and calling setValues method.
什么,我在这里看到的只是静态变量的值将被覆盖,但该方法不overridden.Why这样一个对象?我在这里做错了什么?
我得到的ASDF和清单,亚当和夏娃作为输出
但我需要ASDF和清单,凯拉和索菲亚作为输出。
如何实现这一目标?
编辑
我是多么使用这些值:
在我的基地:
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
}
}
我想,它仍然是相同的 – user2056563
请看看我的编辑,我在我的问题表明 – user2056563
代码是一样的,但要确保你尝试用库项目和正常的应用程序 – user2056563