为什么这些参数不起作用?

时间:2012-06-08 01:52:29

标签: c# nullable out

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 param。

我收到了非法参数错误。

我真的不明白c#中的这些参数功能。任何帮助是极大的赞赏。

1 个答案:

答案 0 :(得分:7)

您需要在参数调用中添加outtemp1不是nullable booleanbool?)。

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