我从网站上获取此代码。它将unicode转换为印地语字体。它使用匹配,但我不遵循如何在别处定义它。它会在'>'附近生成错误。
string input = "0928;0940;0932;092E;";
Regex rx = new Regex(@"([0-9A-Fa-f]{4});");
string output = rx.Replace(input, match => ((char)Int32.Parse(match.Groups[1].Value, NumberStyles.HexNumber)).ToString());
textBox1.Text = output;
更新
错误:当前上下文中不存在“匹配”。
答案 0 :(得分:1)
如果您真正使用C#2.0(基于您的标记),则在C#3.0之前不支持lambda表达式。因此,您无法使用match => ...
。
请尝试使用此string output = ...
行:
string output = rx.Replace(input, delegate(Match match) {
return ((char)Int32.Parse(match.Groups[1].Value, NumberStyles.HexNumber)).ToString();
});