I found this: http://stackoverflow.com/questions/6754609/match-partial-string-in-liststring-in-another-liststring
But I'm wondering if there's an easier way to check if a string is a partial match to player's name
rather than having to create a list every time it's called upon.
What I'm wanting to do is add a partial match to a custom PM system. So that gives you an idea of how often
this function would be used.
But I'm wondering if there's an easier way to check if a string is a partial match to player's name
rather than having to create a list every time it's called upon.
What I'm wanting to do is add a partial match to a custom PM system. So that gives you an idea of how often
this function would be used.
Code:
usedCSS = List<string>
CSS = List<string>
foreach (var str in usedCSS)
{
// FirstOrDefault finds first match or returns default (null for string) if not found.
var match = CSS.FirstOrDefault(s => s.StartsWith(str));
if (match != null)
// get the match.
Response.Write(match + "<br />");
}
else
{
Response.Write("Could not find: " + str + "<br />");
}
}