So there are 2 classes ,and i'm using windows application form, the for has 2 buttons and code for them are as follows :-
Class MyBaseClass
class MyBaseClass
{
public MyBaseClass(string baseClassNeedsThis)
{
MessageBox.Show("thishe base class:" + baseClassNeedsThis);
}
}
Class MySubClass
class MySubclass : MyBaseClass
{
public MySubclass (string baseClassNeedsThis, int anotherValue)
:base(baseClassNeedsThis)
{
MessageBox.Show("Thishe subclass: " + baseClassNeedsThis + "and" + anotherValue);
}
}
And Form1.cs
public partial class Form1 : Form
{
MyBaseClass myBaseClass;
MySubclass mySubClass;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
myBaseClass = new MyBaseClass.MyBaseclass(string baseClassNeedsThis);
}
private void button2_Click(object sender, EventArgs e)
{
mySubClass = new MySubclass.MySubclass(string baseClassNeedsThis , int anotherValue);
}
}
The output expected is up on clicking button1 MyBaseClass messsge should pop up and on clicking button2 both MyBaseClass and MySubClass messages should be displayed, i'm getting a lot of errors
Question
Ch33f
So there are 2 classes ,and i'm using windows application form, the for has 2 buttons and code for them are as follows :-
Class MyBaseClass
class MyBaseClass { public MyBaseClass(string baseClassNeedsThis) { MessageBox.Show("thishe base class:" + baseClassNeedsThis); } }
Class MySubClass
class MySubclass : MyBaseClass { public MySubclass (string baseClassNeedsThis, int anotherValue) :base(baseClassNeedsThis) { MessageBox.Show("Thishe subclass: " + baseClassNeedsThis + "and" + anotherValue); } }
And Form1.cs
The output expected is up on clicking button1 MyBaseClass messsge should pop up and on clicking button2 both MyBaseClass and MySubClass messages should be displayed, i'm getting a lot of errors
What are the corrections to be made in Form1.cs ?
Link to comment
https://www.neowin.net/forum/topic/1321238-code-not-working/Share on other sites
4 answers to this question
Recommended Posts