Created
February 15, 2017 15:47
-
-
Save jskeet/1c63090d847a97cc757352807cfc0a50 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
class Entry {} | |
class WordEntry : Entry {} | |
class CharacterEntry : Entry {} | |
class Program | |
{ | |
public List<WordEntry> WordDataBase = new List<WordEntry>(); | |
public List<CharacterEntry> CharacterDataBase = new List<CharacterEntry>(); | |
public List<Entry> SelectWhere<T>(System.Func<T, bool> predicate) where T : Entry | |
{ | |
if (typeof(T) == typeof(WordEntry)) | |
return WordDataBase | |
.Where((Func<WordEntry, bool>) predicate) | |
.ToList<Entry>(); | |
else if (typeof(T) == typeof(CharacterEntry)) | |
return CharacterDataBase | |
.Where((Func<CharacterEntry, bool>) predicate) | |
.ToList<Entry>(); | |
else | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment