Check if the string end or start with any of the element in an array in C#

We may have used normal EndsWith() extension for the string to check if the string ends with a specific string or character. But, did you ever encountered a situation where you have to check if the string ends with or starts with any of the given strings, may be an array ?. Well I have, and so I wrote an extension for checking if a string ends or starts with any of the element in an array in C#. Once you have this in a static class, say StringExtensions, you can use it in your application if you have access to that class.

Well, I did not use much comments since as you can see its almost self explanatory. Quite simple to do, right ?. Happy coding guys.

Leave a Reply

Your email address will not be published. Required fields are marked *