using System;
using System.Collections.Generic;
using System.Text;
namespace Interface
{
interface Maths
{
void add();//method declaration
void concatenate();//method declaration
//Property declaration
int Add
{
get;
set;
}
//Property declaration
string Concatenate
{
get;
set;
}
}
class Program:Maths
{
//method definition
public void add()
{
int a = 23;
int b = 45;
int c = a + b;
Console.WriteLine(c);
Console.ReadLine();
}
//method definition
public void concatenate()
{
string FirstName = "Hemnath";
string LastName = "Manoharan";
string Name = FirstName + LastName;
Console.WriteLine(Name);
Console.ReadLine();
}
//property definition
public int Add
{
get
{
return c=a+b;
}
set
{
c = value ;
}
}
public int c;//variable declaration
public int a = 12;//variable declaration
public int b = 23;//variable declaration
//property definition
public string Concatenate
{
get
{
return Total=s+g ;
}
set
{
Total = value ;
}
}
public string Total;//variable declaration
public string s = "Hem";//variable declaration
public string g = "nath";//variable declaration
static void Main(string[] args)
{
Maths mat;//instance for interface
Program obj = new Program();//Instance for class
mat = new Program();
Console.WriteLine(mat.Add);
Console.WriteLine(mat.Concatenate);//calling the interface property
Console.ReadLine();//calling the interface property
obj.add();//calling the interface mthod
obj.concatenate();//calling the interface mthod
}
}
}
16 years ago
No comments:
Post a Comment