Professional Documents
Culture Documents
C# Interfaces
C# Interfaces
namespace FirstConsoleProject
{
class MainClass
{
//interface describes what should be in a class and class implements
each method
//name interface with "I" for clarity
interface IItem
{
//don need public or private here
//put get set for a property
string name {get;set;}
int goldValue {get;set;}
//dont need implement methods here
void Equip();
void Sell();
}
//Sword class inherits from IITem, class can inherit from multiple
interfaces
//but cannot inherit from multiple classes!