简体   繁体   English

如何修复Unity2017端口项目Unity 4.x

[英]How can fix it Unity2017 port project Unity 4.x

How can fix this error that occurs when trying to port a Unity 4.x project to Unity2017? 尝试将Unity 4.x项目移植到Unity2017时,如何解决此错误?

Error CS0177: The out parameter `result' must be assigned to before control leaves the current method 错误CS0177:在控制离开当前方法之前,必须将out参数“结果”分配给

public bool TryDequeue(out T result)
{
    Node<T> curHead;
    Node<T> curTail;
    Node<T> next;
    do
    {
        curHead = _head;
        curTail = _tail;
        next = curHead.Next;
        if (curHead == _head)
        {
            if (next == null)
            {
                result = default(T);
                return false;
            }
            if (curHead == curTail)
            {
                Interlocked.CompareExchange<Node<T>>(ref _tail, next, curTail); 
            }
            else
            {
                result = next.Item; 
                if (Interlocked.CompareExchange<Node<T>>(ref _head, 
                    next, curHead) == curHead)
                    break;
            }
        }
    }
    while (true);
    return true;
}

An out parameter must be assigned some value, before the control leaves the function. 在控件离开功能之前,必须为out参数分配一些值。

In your case, the compiler can't determine whether your variable will be assigned or not, because it is being assigned inside of an if statement. 在您的情况下,编译器无法确定是否将变量赋值,因为它是在if语句内部赋值的。

Make sure the parameter is assigned a value in all possible cases or add a default value (start of the method) to make sure it will be assigned at least once. 确保在所有可能的情况下为参数分配一个值,或添加默认值(方法的开始)以确保至少分配一次。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM