c# - Switch statement using string.contains -
i have following method public list<availablefile> getavailablefiles(string rootfolder) { if (directory.exists(rootfolder)) { try { foreach (string f in directory.getfiles(rootfolder)) { if (f.tostring().contains("test")) { files = createfilelist(f); } } } catch (system.exception excpt) { // log stuff } } return files; } what i'm wanting refactor out if statement inside foreach loop, making using of switch statement need check against variety of different words however, i'm struggling put switch statement in due use .contains() , fact need check each of file names may or may not have particular set of characters i'm looking for. is there way in can make use of switch statement or stuck using variety of if statements? edit maybe unclear in wanting do. , seem ho...