What I am trying to do is to have a function lets say called blah in a class lets say class1 that will return "One" to me. Then in another class, say class2 another function also called blah would return "Two".
Up to here it is ok
class TestClass
{
public class Class1
{
public virtual blah()
{
return "One";
}
}
class Class2: Class1
{
public override blah()
{
return "Two";
}
}
Then in my main I would like that depending on a variable or button status the first or second blah() is called but the command to call it must be the same, I cant one time use
Class1 s = new blah();That part I can't work out how to do. It is probably ultra simple or maybe I took the wrong way.
and the second time use
Class2 s = new blah(x);
In any case, your help is much appreciated.
Bechir BejaouiPosted Dec 28, 2008, 6:21 PM
private void button1_Click(object sender, RoutedEventArgs e)
{
CallTheWriteMethod();
}
bool alternative;
private void CallTheWriteMethod()
{
if (alternative == true)
{
MessageBox.Show("alternative 1");
}
if (alternative == false)
{
MessageBox.Show("alternative 2");
}
if (alternative == true) alternative = false;
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
alternative = true;
}