Hi at all,
Is possible to pass a parameter though a delegate or to override it? (I'm
newbie and I'm trying to understand delegates and their use in a real
scenario)
In my scenario I need to override
System.Text.RegularExpression.MatchEvaluator delegate passing it another
parameter.
For a concrete sample I paste some lines of code :
//my regexpression pattern;
Regex regexer= new Regex("myBeatifulPattern", RegexOptions.Multiline);
//Class MatchEvaluator can be created with a delegate to a custom replacing
function
MatchEvaluator myEvaluator = new MatchEvaluator(CommentMatchHandler);
//this replace the occurrences based on regexer patterns
string result = regexer.Replace(code, myEvaluator);
public string MatchHandler(Match match)
{
//DO SOMETHING on MYVALUE
return MYVALUE
}
Well,
in the above sample I'd like to have "MatchHandler" function like :
public string MatchHandler(Match match, string MYPARAMETER)
but is possible? :)
If I declare the function with the new parameter the code wouldn't compile
(and it's in right... it cannot take parameters in new
MatchEvaluator(CommentMatchHandler);
Thanks,
Bob