=] 在 C# 中是什么意思?
What does =] mean in C#?
我遇到了一些以前从未见过的语法;有人可以解释以下代码中第 2 行的语法,特别是 =]
位吗?
//decide what to do with the response we get back from the bridge
client.UploadStringCompleted += (o, args) =] Dispatcher.BeginInvoke(() =]
{
try
{
ResponseTextBox.Text = args.Result;
}
catch (Exception ex)
{
ResponseTextBox.Text = ex.Message;
}
});
不幸的是,网络搜索似乎无法解析 =]
,这让我无法找到解释!
粗略搜索给定代码清单中注释中的文本会导致 this Channel 9 article。此语句出现两次,其中一次以正确的语法 =>
:
呈现相同的 lambda 表达式
//decide what to do with the response we get back from the bridge
client.UploadStringCompleted += (o, args) => Dispatcher.BeginInvoke(() =>
{
try
{
ResponseTextBox.Text = args.Result;
}
catch (Exception ex)
{
ResponseTextBox.Text = ex.Message;
}
});
因此,很明显,您看到的是上述文章作者的部分拼写错误。
AFAIK,没有合法的 C# 构造由字符 =]
组成,按此顺序,甚至考虑空格。在您的特定示例中,这绝对是语法错误。
我遇到了一些以前从未见过的语法;有人可以解释以下代码中第 2 行的语法,特别是 =]
位吗?
//decide what to do with the response we get back from the bridge
client.UploadStringCompleted += (o, args) =] Dispatcher.BeginInvoke(() =]
{
try
{
ResponseTextBox.Text = args.Result;
}
catch (Exception ex)
{
ResponseTextBox.Text = ex.Message;
}
});
不幸的是,网络搜索似乎无法解析 =]
,这让我无法找到解释!
粗略搜索给定代码清单中注释中的文本会导致 this Channel 9 article。此语句出现两次,其中一次以正确的语法 =>
:
//decide what to do with the response we get back from the bridge
client.UploadStringCompleted += (o, args) => Dispatcher.BeginInvoke(() =>
{
try
{
ResponseTextBox.Text = args.Result;
}
catch (Exception ex)
{
ResponseTextBox.Text = ex.Message;
}
});
因此,很明显,您看到的是上述文章作者的部分拼写错误。
AFAIK,没有合法的 C# 构造由字符 =]
组成,按此顺序,甚至考虑空格。在您的特定示例中,这绝对是语法错误。