C# error: Use of unassigned local variable

前端 未结 4 1898
庸人自扰
庸人自扰 2020-12-03 16:43

I\'m not sure why I\'m getting this error, but shouldn\'t this code compile, since I\'m already checking to see if queue is getting initialized?

public stat         


        
4条回答
  •  有刺的猬
    2020-12-03 17:23

    The compiler doesn't know that the Environment.Exit() is going to terminate the program; it just sees you executing a static method on a class. Just initialize queue to null when you declare it.

    Queue queue = null;
    

提交回复
热议问题