Default Implementation

CSharp · Console

/Program.cs

using System;

var test1 = new Test1();
Console.WriteLine(test1.Get); // Test1 has its own implementation and will print 69

ITest test2 = new Test2();
Console.WriteLine(test2.Get); // Test2 falls back on the default implementation and will print 42

interface ITest
{
	int Get => 42;
}

class Test1 : ITest
{
	public int Get => 69;
}

class Test2 : ITest
{
}
;