How much slower would it be to make a list and check if it contains a value over doing multiple or statements?
List<char> validvalues = new List<char>
{
'a', 'b', 'c', 'd'
};
if (validvalues.Contains(value))
{
//do thing
}
versus
if (value == 'a' || value == 'b' || value == 'c' || value == 'd')
{
//do thing
}
Is there an even better way to achieve this that I'm missing?
Edit: First of all I apologize for my stupid question. To clarify this is a drastic oversimplification of my use case which involves checking it against 16 characters and then 32 chars, then 48 chars etc.. up to 256 chars. I was thinking I could append 16 characters at a time to the already existing list and use the same list to check multiple times. Obviously creating a list and checking over it would be slower ig I was really asking how much this would be an issue.