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

Dav*_*ave 2 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 )
{
Run Code Online (Sandbox Code Playgroud)

我所要做的就是有另一种方法,其他参数不是必需的.我bool isAccessToken必须是可空的,challengeOrToken必须是一个out param.

我收到了非法的参数错误.

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

Col*_*son 7

out在需要时不包含在参数调用中,并且temp1不是可以为空的boolean(bool?).

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