Hi folks,
i'm trying to port some Java stuff to C#. I'm just wondering if the following C# code is the equivalent to the original Java source.
Source: Java Code
private static final Pattern SIMPLE_IDENTIFIER_NAME_PATTERN =
Pattern.compile("^[a-zA-Z_][a-zA-Z0-9_]*$");
private static boolean isValidIdentifier(String s) {
Matcher m = SIMPLE_IDENTIFIER_NAME_PATTERN.matcher(s);
return (m.matches() && !reserved.contains(s));
}
Destination: C# Code
private static readonly Regex SIMPLE_IDENTIFIER_NAME_PATTERN =
new Regex("^[a-zA-Z_][a-zA-Z0-9_]*$", RegexOptions.Compiled);
private static bool IsValidIdentifier(string s)
{
Match match = SIMPLE_IDENTIFIER_NAME_PATTERN.Match(s);
return (match.Success && !Reserved.Contains(s));
}
Cheers :)