2012-06-08 32 views
2
public static string ChangeDeviceState(int deviceID, DeviceState nextState) 
{ 
    bool temp1; 
    string temp = ""; 
    return ChangeDeviceState(deviceID, nextState, temp1, temp, "", "", "", "", ""); 
} 

public static string ChangeDeviceState(int deviceID, DeviceState nextState, out bool? isAccessToken, out String challengeOrToken, string accessToken, string serialNumber, string MACAddress, string deviceModel, string answer) 
{ 

所有我想要做的是有另一種方法,其中其他參數是沒有必要的。我bool isAccessToken必須是可空的,並且challengeOrToken必須是一個out參數。爲什麼這些參數不起作用?

我收到了非法參數錯誤。

我真不明白,在C#中,這些參數的功能。任何幫助是極大的讚賞。

回答

7

如果需要,您的參數調用中不包括outtemp1不是nullable booleanbool?)。

public static string ChangeDeviceState(int deviceID, DeviceState nextState) 
{ 
    bool? temp1; 
    string temp; 
    return ChangeDeviceState(deviceID, nextState, out temp1, out temp, "", "", "", "", ""); 
}