Hello,
I am calling a method to display data in a messagebox- unforutunetly - I am just trying to learn override and calling method to use in interface - so my code not working:
class MyBaseClass
{
public static int _num1;
public static int _num2;
public int Num1
{
get
{
return _num1;
}
set
{
_num1 = value;
}
}
public int Num2
{
get
{
return _num2;
}
set
{
_num2 = value;
}
}
public virtual int calculate()
{
return _num1 + _num2;
}
}
}
class myDerivedClass: MyBaseClass
{
private int _num1;
private int _num2;
public override int calculate()
{
return _num1 * _num2;
}
}
private void button3_Click(object sender, EventArgs e)
{
I havemyDerivedClass mdc = new myDerivedClass();
mdc.Num1 = int.Parse(textBox1.Text);
mdc.Num2 = int.Parse(textBox2.Text);
MessageBox.Show(total.ToString()); two textboxes on form and a button- am attempting to code button to display results from data entered in textboxes
I actually want to use first calculate method to get addition result and then override to get multiplication
thank you
I am calling a method to display data in a messagebox- unforutunetly - I am just trying to learn override and calling method to use in interface - so my code not working:
class MyBaseClass
{
public static int _num1;
public static int _num2;
public int Num1
{
get
{
return _num1;
}
set
{
_num1 = value;
}
}
public int Num2
{
get
{
return _num2;
}
set
{
_num2 = value;
}
}
public virtual int calculate()
{
return _num1 + _num2;
}
}
}
class myDerivedClass: MyBaseClass
{
private int _num1;
private int _num2;
public override int calculate()
{
return _num1 * _num2;
}
}
private void button3_Click(object sender, EventArgs e)
{
I havemyDerivedClass mdc = new myDerivedClass();
mdc.Num1 = int.Parse(textBox1.Text);
mdc.Num2 = int.Parse(textBox2.Text);
MessageBox.Show(total.ToString()); two textboxes on form and a button- am attempting to code button to display results from data entered in textboxes
I actually want to use first calculate method to get addition result and then override to get multiplication
thank you

Help
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.

Back to top









