use of interface in c# code example
Example 1: c# interface property
interface InterfaceExample
{
int Number { get; set; }
}
class Example : InterfaceExample
{
int num = 0;
public int Number { get { return num; } set { num = value; } }
}
Example 2: what is inteface and how to use in c#
interface IShape
{
double X { get; set; }
double Y { get; set; }
void Draw();
}
class Square : IShape
{
private double _mX, _mY;
public void Draw() { ... }
public double X
{
set { _mX = value; }
get { return _mX; }
}
public double Y
{
set { _mY = value; }
get { return _mY; }
}
}