I’ve created a method in C# as you can see below
public static IEnumerable<User> QueryTheAD(string filter, string identifier) {
if ( filter == "ANiceString" ) {
// sexy code here
}
}
which works well. However VS rightly shows that not all code path returns a value.
So is it therefore possible for me to specify that filter can only be one of these:
- “Tutor”
- “Year”
- “SecondName”
Use an enum or throw an
ArgumentExceptionif an invalid string was passed.While enums only map to numbers, you could always have a mapping from the enum values to the strings in case you need string names for some reason.