Program how to write c sharp interface program ;
namespace interfaces
{
interface Icalculation
{
void add(int a, int b);
void sub(int a, int b);
}
class calculator:Icalculation
{
int res1;
int res2;
public void add(int a, int b)
{
Console.WriteLine("Addition is:" + (a + b));
}
public void sub(int a, int b)
{
Console.WriteLine("Subtraction is:" + (a - b));
}
static void Main(string[] args)
{
calculator cl = new calculator();
cl.add(100, 100);
Console.WriteLine();
cl.sub(200, 100);
Console.WriteLine();
Console.ReadLine();
}
}
}
namespace interfaces
{
interface Icalculation
{
void add(int a, int b);
void sub(int a, int b);
}
class calculator:Icalculation
{
int res1;
int res2;
public void add(int a, int b)
{
Console.WriteLine("Addition is:" + (a + b));
}
public void sub(int a, int b)
{
Console.WriteLine("Subtraction is:" + (a - b));
}
static void Main(string[] args)
{
calculator cl = new calculator();
cl.add(100, 100);
Console.WriteLine();
cl.sub(200, 100);
Console.WriteLine();
Console.ReadLine();
}
}
}
0 comments: