-
Junior Member
Interface methods body
In interface i wrote two methods ie without body and i want to write the body one in one class other in another is it possible
Answer: Actually in an interface I wrote two methods without body ie definitions and I want two implement ie writing total body and using it in one method in one class and other method in other class is it possible.
see below example and explain the problem
take windows application and take a button control
interface i
{
void read();
void print();
}
class test : i
{
public void read()
{
MessageBox.Show("from read...test");
}
}
class best : i
{
public void print()
{
MessageBox.Show("from print...best");
}
}
private void button1_Click(object sender, EventArgs e)
{
test t = new test();
best b = new best();
i x = new test();
x.read();
i y = new best();
y.print();
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules