Reputation: 640
I am working on Windows Phone app Development,
I have 3 projects
1) Library Project
2) Child Project 1 referencing the library project
3) Child Project 2 referencing the library project
In Library project it contains all xaml files,.cs files etc... In my child project it contain only a MainPage.xaml and its .cs file where I am navigating it to a page in my library project.
But there are few condition in my library project code and it will work based on those conditions like :
In my library project a class can contain:
if(language == "JAVA"){
// alert with text as "Android"
}else{
// alert with text as "Windows"
}
here the string JAVA might be defined in library project like this:
public String LanguageName(){
return "JAVA";
}
But in my child project it can be override like:
public override String LanguageName(){
return "C#";
}
So when I execute in should show me a alert with Windows as text , if its not defined in child project then it should alert with default value as Android.
How to achieve this ?
Upvotes: 0
Views: 88
Reputation: 152596
To override
a method, the base method must be virtual
:
// in base class
public virtual String LanguageName(){
return "JAVA";
}
// in derived class
public override String LanguageName(){
return "C#";
}
Upvotes: 1