无法将类型'void'隐式转换为'bool'

时间:2014-03-11 06:13:33

标签: c# type-conversion implicit-conversion

为什么这段代码:

    protected bool IsServerPeer(InitRequest initRequest)
    {
        return _subServerCollection.IsServerPeer(initRequest);
    }

创建错误:

无法隐式将'void'类型转换为'bool'

2 个答案:

答案 0 :(得分:1)

可能是因为_subServerCollection.IsServerPeer()的返回类型为void

答案 1 :(得分:0)

检查_subServerCollection.IsServerPeer的返回值。它可能不会返回布尔值。从错误消息中,上述方法可能返回类型void(nothing returned from the method)

相关问题