1.6 KiB
		
	
	
	
	
	
	
	
			
		
		
	
	
			1.6 KiB
		
	
	
	
	
	
	
	
title
| title | 
|---|
| Interface | 
Using interfaces allows us to change our implementation in our project without breaking other parts, and only have to change the one place where the object is created.
Interface Example:
public Interface IUserFavoriteFood
{
  void AddFood();
  Task<User> EatFavoriteFood(int id);
}
Interface inheritance and implementation:
public class UserHungry : IUserFavoriteFood
{
  public AddFood()
  {
    // Implementation:
    // A method to add food.
  }
  public Task<User> EatFavoriteFood(int id)
  {
    // Implementation:
    // A method to Eat food by id.
  }
}