Skip to content

Instantly share code, notes, and snippets.

public sealed class Golfer
: IDriver
{
public void Drive()
{
var value = RandomNumberGenerator.GetInt32(250, 320);
Console.WriteLine($"{value} yards");
}
public override void Stop()
public abstract class Driver
{
protected Driver() { }
public abstract void Drive();
public virtual void Stop() { }
}
public sealed class GolferDriver
public class ModernGolfer
: IModernDriver<ModernGolfer>
{
public static void Drive(IEnumerable<ModernGolfer> modernGolfers)
{
foreach(var modernGolfer in modernGolfers)
{
modernGolfer.Drive();
}
}
public interface IModernDriver<TSelf>
where TSelf : IModernDriver<TSelf>
{
static abstract void Drive(IEnumerable<TSelf> modernDrivers);
void Drive();
void Stop() { }
}
public interface IDriver
{
public static void Drive(IEnumerable<IDriver> drivers)
{
foreach(var driver in drivers)
{
driver.Drive();
}
}
public interface IDriver
{
void Drive();
void Stop();
}
public interface IDriver
{
void Drive();
void Stop() { }
}
287 yards
177 MPH
public static void Drive(IEnumerable<IDriver> drivers)
{
foreach(var driver in drivers)
{
driver.Drive();
}
}
Drive(new IDriver[] { new Golfer(), new Racer() });
public sealed class Golfer
: IDriver
{
public void Drive()
{
var value = RandomNumberGenerator.GetInt32(250, 320);
Console.WriteLine($"{value} yards");
}
}