using System;
interface IName
{
string Name { get; set; }
}
class Employee : IName
{
public string Name { get; set; }
}
class Company : IName
{
private string _company { get; set; }
public string Name
{
get
{
return _company;
}
set
{
_company = value;
}
}
}
class Client
{
static void Main(string[] args)
{
IName e = new Employee();
e.Name = "Tim Bridges";
IName c = new Company();
c.Name = "Inforsoft";
Console.WriteLine("{0} from {1}.", e.Name, c.Name);
Console.ReadKey();
}
}
/*output:
Tim Bridges from Inforsoft.
*/
public interface ISampleInterface
{
// Property declaration:
string Name
{
get;
set;
}
}
interface InterfaceExample
{
int Number { get; set; }
}
class Example : InterfaceExample
{
int num = 0;
public int Number { get { return num; } set { num = value; } }
}
// C# program to demonstrate working of
// interface
using System;
// A simple interface
interface inter1
{
// method having only declaration
// not definition
void display();
}
// A class that implements interface.
class testClass : inter1
{
// providing the body part of function
public void display()
{
Console.WriteLine("Sudo Placement GeeksforGeeks");
}
// Main Method
public static void Main (String []args)
{
// Creating object
testClass t = new testClass();
// calling method
t.display();
}
}