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
Code
Class1 s = new blah();
and the second time use
Class2 s = new blah(x);In any case, your help is much appreciated.
Bechir BejaouiRank #144 · 15.9K pointsPosted Dec 28, 2008, 1:21 PM EST
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;
}