Current in my code, if statement is too big and many repetitions.
if (!String.Equals(node.Name, "A", StringComparison.OrdinalIgnoreCase)
&& !String.Equals(node.Name, "B", StringComparison.OrdinalIgnoreCase)
&& !String.Equals(node.Name, "C", StringComparison.OrdinalIgnoreCase)
&& ...
I would like to make it concise. But my idea is only to create a function and passing List or Array as param.
List<String> target = new List<String>() { "A", "B", "C" ... };
MultipleStringCompare(node.Name, target, , StringComparison.OrdinalIgnoreCase);
Is there any more beautiful way to make it simple without making any function in modern C# syntax?
Aucun commentaire:
Enregistrer un commentaire