Friday, October 12, 2007
Minor String-Array Helper Method
This is a pretty small item, but I find it useful in a lot of scenarios: There now is a new ArrayContainsString() method on the StringHelper object. It provides a quick way to check whether a certain string array contains a certain string, and it can do so in a case insensitive fashion:
string[] testArray = new string[] { "One", "Two", "Three" };
bool result1 = StringHelper.ArrayContainsString(testArray, "one", true); // returns true
bool result2 = StringHelper.ArrayContainsString(testArray, "one"); // returns false
bool result3 = StringHelper.ArrayContainsString(testArray, "One"); // returns true
bool result4 = StringHelper.ArrayContainsString(testArray, "Four"); // returns false
As I said, this is not an earth-shaking feature, but it is kinda nifty...
Posted @ 2:26 PM by Egger, Markus (markus@code-magazine.com)
Post a Comment:
Comment Title (required):
Your Name (optional):
Your Email (optional):
Your Web Site (optional):
Your Comment (required):