Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/260.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.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# 将一个方法的参数值放入另一个类';s法_C# - Fatal编程技术网

C# 将一个方法的参数值放入另一个类';s法

C# 将一个方法的参数值放入另一个类';s法,c#,C#,在我的方法中,我从我的数据表中得到一个int值 public void GetListing(string url,int ID) 我想从另一个方法访问这个ID,然后给它分配一个更新值,然后保存在我的表中 有可能吗 updateMethod(int ID,int Status) 您应该通过传递ID从GetListing()调用updateMethod。因此GetListing的签名如下所示: public void GetListing(string url,int ID) { //So

在我的方法中,我从我的数据表中得到一个int值

public void GetListing(string url,int ID)
我想从另一个方法访问这个ID,然后给它分配一个更新值,然后保存在我的表中 有可能吗

updateMethod(int ID,int Status)

您应该通过传递ID从
GetListing()
调用
updateMethod
。因此
GetListing
的签名如下所示:

public void GetListing(string url,int ID)
{
  //Some code here 
  int status=1; // this will be the value of status
  updateMethod(ID, status); // this will call the updateMethod
}
updateMethod()将是这样的

updateMethod(int ID,int Status)
{
 // do something
}

您应该通过传递ID从
GetListing()
调用
updateMethod
。因此
GetListing
的签名如下所示:

public void GetListing(string url,int ID)
{
  //Some code here 
  int status=1; // this will be the value of status
  updateMethod(ID, status); // this will call the updateMethod
}
updateMethod()将是这样的

updateMethod(int ID,int Status)
{
 // do something
}

在有更新方法的地方创建类的对象,在列表类下创建对象,然后可以为该方法赋值

在有更新方法的地方创建类的对象,将对象放在你的listing类下,然后你可以给该方法赋值

你在哪里/什么时候调用你的
updateMethod
?在我的GetListing方法下,我调用该方法,并想将ID传递给该方法,但问题是每次Get listing都会得到一个动态/不同的ID,所以这是否可以在我的更新方法是通过ID访问的?你在哪里/什么时候调用你的
updateMethod
?在我的GetListing方法下,我调用该方法并想将ID传递给该方法,但问题是每次Get listing都会获得一个动态/不同的ID,所以通过ID访问我的更新方法是否可以更改IDID?我会试试。在此之前,请告诉我更新方法中的1是什么?最后一件事,我每次都能处理不同的ID吗?因为每次我在GetListing方法和pass to update方法中都会得到不同的ID??它将使用您当时决定传递给
GetListing()
方法的任何参数,建议将
GetListing()
重命名为
GetListing()
,方法通常在开始时用小写字母表示。在此之前,请告诉我更新方法中的1是什么?最后一件事,我每次都能处理不同的ID吗?因为每次我在GetListing方法和pass to update方法中都会得到不同的ID??它将使用您当时决定传递给
GetListing()
方法的任何参数,建议将
GetListing()
重命名为
GetListing()
,方法通常在开始时用小写字母表示。编写代码可能会更好地解释您的观点,现在有点不清楚您的意思。编写代码可能会更好地解释您的观点,现在有点不清楚您的意思