Skip to content

Instantly share code, notes, and snippets.

@jagregory
Created July 5, 2010 21:16
Show Gist options
  • Save jagregory/464695 to your computer and use it in GitHub Desktop.
Save jagregory/464695 to your computer and use it in GitHub Desktop.
interface ILine
{}
class AdditionLine : ILine {}
class SubtractionLine : ILine {}
class ModificationLine : ILine {}
void ProcessLines(IList<ILine> lines) {}
var additions = new List<AdditionLine>();
ProcessLines(additions) // blegh, doesn't work
// another...
interface ISnippet
{
IEnumerable<ILine> Lines { get; }
}
class AdditionSnippet
{
private List<AdditionLine> lines = new List<AdditionLine>();
// Blegh, fails. Gotta use lines.Cast<ILine>();
public IEnumerable<ILine> Lines
{
get { return lines; }
}
public AdditionSnippet(IEnumerable<AdditionLine> additions)
{
lines = new List<AdditionLine>(additions);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment