我看过一个示例C#代码,如下所示:
private static string GetCommandLine(Process process)
{
string cmd = "";
using (var s = new ManagementObjectSearcher("SELECT CommandLine FROM Win32_Process WHERE ProcessId = " + process.Id))
{
foreach (var @object in s.Get())
{
if (cmd.Length > 0) cmd += " ";
cmd += @object["CommandLine"];
}
}
return cmd;
}
循环变量中@的目的是什么?
答案 0 :(得分:1)
如果要将保留字用作变量名,请在前面添加@符号。