An Introduction to interface.
Windowform3:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using mutilevelinheritancebyinterface;
namespace WindowsFormsApplication4
{
public partial class Form1 : Form
{
public
Form1()
{
InitializeComponent();
}
simple
obj = new simple();
private
void button3_Click(object
sender, EventArgs e)
{
int
x = int.Parse(textBox1.Text);
int
y = int.Parse(textBox2.Text);
MessageBox.Show(obj.add(x,y).ToString());
}
private
void button4_Click(object
sender, EventArgs e)
{
int
x = int.Parse(textBox1.Text);
int
y = int.Parse(textBox2.Text);
MessageBox.Show((obj.sub(x,y)).ToString());
}
private
void button5_Click(object
sender, EventArgs e)
{
Imyint1
my;
my = obj;
MessageBox.Show(my.add
(2,6).ToString ());
}
private
void button1_Click(object
sender, EventArgs e)
{
Imyint1
my;
//my =
obj;
//my.display();
((obj)my).display();
}
private
void button2_Click(object
sender, EventArgs e)
{
Imyint2
my;
my = obj;
my.display();
}
private
void button6_Click(object
sender, EventArgs e)
{
Imyint2
my;
my = obj;
MessageBox.Show(my.sub(3,
2).ToString());
}
}
}
mutilevelinheritancebyinterface
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace mutilevelinheritancebyinterface
{
public interface Imyint1
{
void
display();
int add(int a,int b);
}
public interface Imyint2
{
void
display();
int sub(int a,int b);
}
public class simple:Imyint1,Imyint2
{
void Imyint1.display()
{
MessageBox.Show("i am the display of Imyint1");
}
public int add(int a, int b)
{
return
(a + b);
}
public int sub(int a, int b) {
return
(a - b);
}
void Imyint2.display()
{
MessageBox.Show("i am in my int 2");
}
int Imyint1.add(int a,
int b)
{
return
(a +b);
}
int Imyint2.sub(int a,
int b)
{
return
(a - b);
}
}
}
Posted By:Tanuj Kumar
On:Shareyourconscience
Comments
Post a Comment