Skip to content

Instantly share code, notes, and snippets.

View DanielPaulWilkinson's full-sized avatar
🏠
Working from home

Daniel Wilkinson DanielPaulWilkinson

🏠
Working from home
View GitHub Profile
private int _numberOfLegs = 0;
private int NumberOFLegs
{
get { return _numberOfLegs; }
set { _numberOfLegs = value; }
}
private int NumberOfLegs;
private int GetNumberOfLegs()
{
return NumberOfLegs;
}
public void SetNumberOfLegs(int numberOfLegs)
{
NumberOfLegs = numberOfLegs;
public class Cat : Animal
{
public new void Move()
{
Console.WriteLine("I am not going to do anything that my master tells me to!");
}
}
public class Animal : IEat, ISleep
{
public void Eat()
{
Console.WriteLine("I am eating...");
}
public virtual void Move()
{
Console.WriteLine();
public interface IEat
{
void Eat();
void NotHungry();
}
public interface ISleep
{
void Sleep();
}
@DanielPaulWilkinson
DanielPaulWilkinson / Animal.cs
Created May 16, 2021 20:49
different types of inheritance
public class Animal
{
public bool CanFly = false;
public void Move()
{
Console.WriteLine("I am walking!");
}
}
@DanielPaulWilkinson
DanielPaulWilkinson / Program.cs
Created May 16, 2021 20:10
Program showing inheritance
public class Program
{
static void Main(string[] args)
{
Animal animal = new Animal();
animal.Move();
Cat cat = new Cat();
cat.Move();
}
@DanielPaulWilkinson
DanielPaulWilkinson / Animal.cs
Last active May 16, 2021 20:10
Showing basic inheritance in C#
public class Animal
{
public void Move()
{
Console.WriteLine("I am walking!");
}
}
public class Cat : Animal
{
var recipes = _spoonacular.Get5Recipies("pizza").GetAwaiter().GetResult();
foreach(Recipe recipe in recipes)
{
Console.WriteLine(recipe.Title);
}
public class SpoonacularService : ISpoonacularService
{
public async Task<IEnumerable<Recipe>> Get5Recipies(String query)
{
List<Recipe> recipes = new List<Recipe>();
var url = $"https://api.spoonacular.com/recipes/complexSearch";
var parameters = $"?query={query}&apiKey={Consts.SpoonacularKey}&number=5";