2016-04-22 55 views
1

我得到我的方法來自我的數據表中的一個int值取參數值到另一個類的方法

public void GetListing(string url,int ID) 

我想從另一個方法來訪問這個ID,然後分配一個更新值它,然後保存在我的表 是否有可能這樣做?

updateMethod(int ID,int Status) 
+0

在哪裏/你什麼時候打電話給你'updateMethod'? –

+0

在我的GetListing方法下即時調用該方法,並想傳遞ID到該方法,但事情是每次獲取列表將獲得一個動態/不同的ID所以這可能使我的更新方法中的ID更改通過ID訪問它? –

回答

1

你應該通過傳遞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 
} 
+0

會嘗試it.before請告訴我更新方法中的1是什麼? –

+0

這將是狀態的值;最後看到更新 –

+0

,我每次都能處理不同的ID嗎?因爲我在每次獲取GetListing方法中的不同ID並傳遞更新方法? –

-1

讓你的類的對象,你有你的更新方法,讓你的上市類下的對象,然後你可以將值分配給該方法

+0

編寫代碼可能會更好地解釋你的觀點,在此刻,你的意思有點不清楚 – Draken

相關問題