here, string comparison specifies the culture, case and sort rules to be used by string methods.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Method to check if a string value exists in a list. Will be quicker than Linq. | |
/// </summary> | |
/// <param name="list">The list of strings.</param> | |
/// <param name="match">The item to match.</param> | |
/// <param name="comparisonType">The type of comparison to perform.</param> | |
/// <returns>True/false indication of whether the item exists in the list.</returns> | |
private bool ListMatch(IList<string> list, string match, StringComparison comparisonType) | |
{ | |
bool result = false; | |
if ((list != null) && (list.Count > 0)) | |
{ | |
foreach (string item in list) | |
{ | |
int compare = string.Compare(item, match, comparisonType); | |
if (compare == 0) | |
{ | |
result = true; | |
} | |
} | |
} | |
return result; | |
} |
If you have any questions, post here. Also, provide your valuable suggestions and thoughts in form of comments in the section below.
Thank you !!!
No comments:
Post a Comment