Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/273.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# “L”运算符后缺少操作数_C# - Fatal编程技术网

C# “L”运算符后缺少操作数

C# “L”运算符后缺少操作数,c#,C#,我的代码中出现以下错误: “L”运算符后缺少操作数 我调试了代码,发现它出现在下面的行中: DataRow[] documents = this.DataSet.Results_Documents.Select(String.Format("DocumentControlNumber = '{0}'", dcn), null, DataViewRowState.CurrentRows); 在这里,当dcn在其完整字符串中包含“”时,就会发生这种情况 确切的原因是什么 例如:Sheldon的dc

我的代码中出现以下错误:

“L”运算符后缺少操作数

我调试了代码,发现它出现在下面的行中:

DataRow[] documents = this.DataSet.Results_Documents.Select(String.Format("DocumentControlNumber = '{0}'", dcn), null, DataViewRowState.CurrentRows);
在这里,当dcn在其完整字符串中包含“”时,就会发生这种情况

确切的原因是什么

例如:Sheldon的dcn:-Nat'l Bk

选择要求字符串采用特定格式,当您有“字符串”时,该字符串不再有效。您需要通过使用重新绘制每个“引用”来转义引号

如果dcn是一个字符串,则不需要.ToString

选择要求该字符串采用特定格式,当您有一个“字符串”时,该字符串不再有效。您需要通过使用重新绘制每个“引用”来转义引号

如果dcn是一个字符串,则不需要.ToString

在这里,当dcn在其完整字符串中包含“”时,就会发生这种情况

是的;使用串联的常见问题;让我们使用示例dcn作为您问题中Sheldon的Nat'l Bk;查询现在是:

DocumentControlNumber = 'Nat'l Bk of Sheldon'
这是畸形的。因为这不允许正确的参数化,所以需要转义该值;如果非要我猜的话,我想:

DocumentControlNumber = 'Nat''l Bk of Sheldon'

注意\n C还需要转义或使用逐字字符串文本

任何一个都可以通过字符串实现;例如,将参数中的dcn.Replace'转换为string.Format

在这里,当dcn在其完整字符串中包含“”时,就会发生这种情况

是的;使用串联的常见问题;让我们使用示例dcn作为您问题中Sheldon的Nat'l Bk;查询现在是:

DocumentControlNumber = 'Nat'l Bk of Sheldon'
这是畸形的。因为这不允许正确的参数化,所以需要转义该值;如果非要我猜的话,我想:

DocumentControlNumber = 'Nat''l Bk of Sheldon'

注意\n C还需要转义或使用逐字字符串文本

任何一个都可以通过字符串实现;例如dcn.Replace',在参数to string.Format中。

dcn的示例值??为什么文档编号包含撇号?是否需要用两个单引号替换单引号以转义它?dcn的示例值??为什么文档编号包含撇号?您是否需要将单引号替换为两个单引号来转义它?