[英]How can fix it Unity2017 port project Unity 4.x
尝试将Unity 4.x项目移植到Unity2017时,如何解决此错误?
错误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;
}
在控件离开功能之前,必须为out参数分配一些值。
在您的情况下,编译器无法确定是否将变量赋值,因为它是在if语句内部赋值的。
确保在所有可能的情况下为参数分配一个值,或添加默认值(方法的开始)以确保至少分配一次。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.