Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/312.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#和Smartsheet API将当前rowID传递给CopyOrMoveRowDirective语句?_C#_Smartsheet Api_Smartsheet C# Sdk V2 - Fatal编程技术网

如何使用C#和Smartsheet API将当前rowID传递给CopyOrMoveRowDirective语句?

如何使用C#和Smartsheet API将当前rowID传递给CopyOrMoveRowDirective语句?,c#,smartsheet-api,smartsheet-c#-sdk-v2,C#,Smartsheet Api,Smartsheet C# Sdk V2,我有C#中的代码,可以将一行从一个工作表移动到另一个工作表,但我只能在CopyOrMoveRowDirective行中硬编码行id时才能使其工作 将行id传递到语句中的语法是什么?我尝试了用rowm.ID代替80233296095108,但出现了语法错误 下面是代码的简化版本,但在循环时需要传入当前的rowid foreach (Row rowm in sheet.Rows) { { CopyOrMoveRowDestination destination

我有C#中的代码,可以将一行从一个工作表移动到另一个工作表,但我只能在
CopyOrMoveRowDirective
行中硬编码行id时才能使其工作

将行id传递到语句中的语法是什么?我尝试了用
rowm.ID
代替
80233296095108
,但出现了语法错误

下面是代码的简化版本,但在循环时需要传入当前的rowid

foreach (Row rowm in sheet.Rows)

{

       {

          CopyOrMoveRowDestination destination = new CopyOrMoveRowDestination { SheetId = 336102784558980 };

          CopyOrMoveRowDirective directive = new CopyOrMoveRowDirective { RowIds = new long[] { 80233296095108 }, To = destination };

          CopyOrMoveRowResult results = smartsheet.SheetResources.RowResources.MoveRowsToAnotherSheet(3267158118557572, directive, null, null);

       }

}

经过反复试验,我终于成功了。它需要额外的一行代码和对CopyOrMoveRowDirective行的更改。我添加了long rowmId=rowm.Id.Value;作为一个新的代码行。然后将CopyOrMoveRowDirective=new CopyOrMoveRowDirective{RowIds=new long[]{rowmId}更新为=destination}

我很高兴听到你这么做了。您是否尝试过在COPYORMOVEROW指令中执行相同的声明?在声明指令变量时,您可以尝试RowIds=new long[]{rowm.Id.Value},而不是执行新行。